Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Toolbar with controls
#1
When you need to have controls on a toolbar, you create a toolbar hook function, and use CreateControl to create controls. It is quite much work, because you cannot use the Dialog Editor. But there is an easier way. You can create a dialog using the Dialog Editor, and show it as child of the toolbar. In the Dialog Editor, remove all dialog styles except WS_VISIBLE, and add DS_CONTROL style. In the toolbar hook function, under WM_CREATE, call ShowDialog(.... hWnd 1 WS_CHILD).

Example:

Toolbar ToolbarWithChildDialog
Code:
Select All      Help
;/mov0 264 132 /hook TWCD_Proc
Notepad :run "notepad.exe"

Function TWCD_Proc
Code:
Select All      Help
;/ToolbarWithChildDialog
function# hWnd message wParam lParam

sel message
,case WM_CREATE
,int hDlg=ShowDialog("TWCD_Dialog" &TWCD_Dialog 0 hWnd 1 WS_CHILD)
,mov 0 22 hDlg
,RECT r; GetClientRect(hDlg &r); siz r.right r.bottom+22 hWnd ;;autosize, because dialog dimensions depend on system font settings
,
,case WM_DESTROY
,

Function TWCD_Dialog
Code:
Select All      Help
;\Dialog_Editor
function# hDlg message wParam lParam

;BEGIN DIALOG
;0 "" 0x10000444 0x0 0 0 267 135 "Form"
;1102 Button 0x54012003 0x0 104 80 48 12 "Check"
;1002 Edit 0x54030080 0x200 144 60 96 14 ""
;1001 Static 0x44020000 0x4 94 60 48 13 "Page0"
;1101 Static 0x44020000 0x4 104 62 48 13 "Page1"
;1201 Static 0x44020000 0x4 110 70 48 13 "Page2"
;3 SysTabControl32 0x54000040 0x0 0 2 266 132 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010804 "" " "


type TCITEM mask dwState dwStateMask $pszText cchTextMax iImage lParam

;messages
sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,
,int htb=id(3 hDlg)
,TCITEM ti.mask=WINAPI.TCIF_TEXT
,ti.pszText="A"
,SendMessage htb WINAPI.TCM_INSERTITEMA 0 &ti
,ti.pszText="B"
,SendMessage htb WINAPI.TCM_INSERTITEMA 1 &ti
,ti.pszText="C"
,SendMessage htb WINAPI.TCM_INSERTITEMA 2 &ti
,
,goto g11
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
,case WM_NOTIFY goto messages3
ret
;messages2
sel wParam
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
;messages3
NMHDR* nh=+lParam
sel nh.code
,case WINAPI.TCN_SELCHANGE
,_i=SendMessage(nh.hwndFrom WINAPI.TCM_GETCURSEL 0 0)
,;g11
,DT_Page hDlg _i

Tested with QM 2.1.8.


Forum Jump:


Users browsing this thread: 1 Guest(s)