Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom control event
#24
I reinstalled the English version of the system and QM2.8.2, the following code, still prompts an error

Function DialogSubclassExample
Code:
Copy      Help
out
QMITEM qmac; int imac
ARRAY(str) amac
rep
,imac=qmitem(-imac 2 &qmac 1)
,if(imac=0) break
,if qmac.itype=1
,,amac[]=qmac.name

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Win Dialog subclass example"
;3 Button 0x54032000 0x0 116 52 100 14 "Right click on the popup"
;4 ComboBox 0x54230641 0x0 8 8 96 120 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""

str controls = "4"
str cb4
cb4=amac
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,int hbc=id(3 hDlg)
,int hcbc=child("" "ComboLBox" id(4 hDlg) 0x0 "id=1000") ;;list
,SetWindowSubclass hbc &sub.WndProc_Subclass 1 0
,SetWindowSubclass hcbc &sub.WndProc_Subclass 1 0
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1

#sub WndProc_Subclass
function# hwnd message wParam lParam uIdSubclass dwRefData

;This function can be used with SetWindowSubclass as window procedure.
;<help>SetWindowSubclass</help> is the recommended way to subclass windows. Easier and safer than SetWindowLong. Example: SetWindowSubclass(hwnd &sub.WndProc_Subclass 1 0)

;OutWinMsg message wParam lParam ;;uncomment to see received messages
sel message
,case WM_RBUTTONUP
,Acc a.FromMouse
,int rcrn=a.Role
,str rcitem=a.Name
,if rcrn=34
,,int rccbh=a.Hwnd
,,int rciti= a.elem -1
,,mac "sub.rcmessage" "" rcrn rcitem rciti rccbh
,else
,,mac "sub.rcmessage" "" rcrn rcitem
int R=DefSubclassProc(hwnd message wParam lParam)

sel message
,case WM_NCDESTROY
,RemoveWindowSubclass(hwnd &sub.WndProc_Subclass uIdSubclass) ;;replace ThisFunction with the name of this function or subfunction (eg sub.WndProc_Subclass)
,;case ...

ret R

#sub rcmessage
function# i [~item][#itemindex][#chwnd]
str mtext
sel i
,case 43:
,mtext="button was right clicked"
,case 34:
,,;mtext.format("combo list item: (%s) was right clicked" item)
,,CB_SelectItem(chwnd itemindex)
,,mac+ item
,case 33:
,,mtext="combo list was right clicked on an empty item"
if(!empty(mtext))
,mes(mtext)


Attached Files Image(s)
   


Messages In This Thread
Custom control event - by win - 04-22-2019, 12:00 PM
RE: Custom control event - by Kevin - 04-22-2019, 01:58 PM
RE: Custom control event - by win - 04-22-2019, 02:09 PM
RE: Custom control event - by Kevin - 04-23-2019, 03:17 AM
RE: Custom control event - by win - 04-23-2019, 03:51 AM
RE: Custom control event - by Kevin - 04-23-2019, 03:57 AM
RE: Custom control event - by win - 04-23-2019, 04:22 AM
RE: Custom control event - by Kevin - 04-23-2019, 06:42 AM
RE: Custom control event - by win - 04-23-2019, 07:16 AM
RE: Custom control event - by Kevin - 04-23-2019, 01:45 PM
RE: Custom control event - by win - 04-23-2019, 02:02 PM
RE: Custom control event - by Kevin - 04-23-2019, 02:09 PM
RE: Custom control event - by win - 04-23-2019, 02:11 PM
RE: Custom control event - by Kevin - 04-23-2019, 02:12 PM
RE: Custom control event - by win - 04-23-2019, 02:13 PM
RE: Custom control event - by Kevin - 04-23-2019, 02:16 PM
RE: Custom control event - by win - 04-23-2019, 02:18 PM
RE: Custom control event - by Kevin - 04-23-2019, 02:19 PM
RE: Custom control event - by win - 04-23-2019, 02:20 PM
RE: Custom control event - by Kevin - 04-23-2019, 02:21 PM
RE: Custom control event - by win - 04-23-2019, 02:27 PM
RE: Custom control event - by Kevin - 04-23-2019, 02:34 PM
RE: Custom control event - by win - 04-23-2019, 03:02 PM
RE: Custom control event - by win - 04-26-2019, 01:45 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)