Example: Using a Dialog

In the following example a dialog box identified with number # 1 is displayed when the editor extension keyboard shortcut Shift+Ctrl+9 is pressed. Per editor extension 31 dialogbox can be displayed simultaneously. Their id numbers range from 1 to 31.

 

Sub Gfa_Ex_9

Dialog # 1, 10, 10, 100, 170, "TestDlg", WS_SYSMENU

PushButton "but &A", 100, 10, 10, 50, 20

PushButton "but &B", 101, 10, 32, 50, 20

PushButton "but &C", 102, 10, 54, 50, 20

DefPushButton "Ok", IDOK, 10, 76, 50, 20

PushButton "Cancel", IDCANCEL, 10, 98, 50, 20

EditText "", 200, 10, 120, 50, 22

EndDialog

ShowDialog # 1

~SetFocus(Dlg(1, IDOK))

EndSub

 

Sub Gfa_CB(h%, m%, w%, l%, r%, f?)

If h% = Dlg(1)

Switch m

Case WM_COMMAND

Switch w

Case 100 : MsgBox "Button A pressed"#10 & _Win$(Dlg(1, 200))

Case 101 : cmdB_Click

Case 102 : MsgBox "Button C pressed"

Case IDOK : MsgBox "Ok pressed" #10 & _Win$(Dlg(1, 200)) : CloseDialog # 1

Case IDCANCEL : MsgBox "Cancel" : CloseDialog # 1

EndSwitch

Case WM_CLOSE

MsgBox "Cancel - Close"

EndSwitch

EndIf

EndSub

 

Sub cmdB_Click

MsgBox "Button B pressed" #10 & _Win$(Dlg(1, 200))

EndSub

{Created by Sjouke Hamstra; Last updated: 04/10/2014 by James Gaite}