04-23-2019, 03:17 AM
Function DialogSubclassExample
str s=
;one
;two
;three
;four
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=s
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 _s _i ;;uncomment to see received messages
sel message
,case WM_RBUTTONUP
,Acc a.FromMouse
,int mi=iif((a.elem<>0) 2 1)
,mac "sub.rcmessage" "" mi
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
sel i
,case 1
,mes("button was right clicked")
,case 2
,mes("combo list was right clicked")