Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Q) Function pointers and usage
#5
Dialog function is called directly by Windows. Windows cannot call member functions because it does not know the variable. Use intermediate UDF that retrieves variable address and calls member function.

Macro
Code:
Copy      Help
class ClassDlg a
ClassDlg cd
cd.ShowDlg

Member function ClassDlg.ShowDlg
Code:
Copy      Help
str controls = "4"
str c4Che
if(!ShowDialog("ClassDlg_DlgProc" &ClassDlg_DlgProc &controls 0 0 0 0 &this)) ret

Member function ClassDlg.DlgProc
Code:
Copy      Help
function# hDlg message wParam lParam

;messages
sel message
,case WM_INITDIALOG ;;don't call DT_InitDialog!
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3 mes "Button"
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1

Function ClassDlg_DlgProc
Code:
Copy      Help
;\Dialog_Editor
function# hDlg message wParam lParam

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Form"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032000 0x0 10 10 48 14 "Button"
;4 Button 0x54012003 0x0 170 10 48 12 "Check"
;END DIALOG
;DIALOG EDITOR: "" 0x2010900 "" ""


if(message=WM_INITDIALOG) DT_Init(hDlg lParam)
ClassDlg* p=+DT_GetParam(hDlg)
if(p) p.DlgProc(hDlg message wParam lParam)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)