Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_Toolbar = 500
%IDC_ButtonX = 501
%IDC_ButtonY = 502
Global hDlg, hToolbar As Dword, OldProc As Long
Function PBMain()
Dialog New Pixels, 0, "Toolbar Test",,, 500,250, %WS_OverlappedWindow, To hDlg
Control Add Toolbar, hDlg, %IDC_Toolbar,"", 0,0,0,0
Control Handle hDlg, %IDC_Toolbar To hToolbar
Toolbar Add Button hDlg, %IDC_Toolbar, 1, 200, %TbStyle_Button, "x"
Toolbar Add Button hDlg, %IDC_Toolbar, 2, 201, %TbStyle_Button, "y"
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
OldProc = SetWindowLong(hToolbar, %GWL_WndProc, CodePtr(NewProc)) 'subclass a control
Case %WM_ContextMenu
Dialog End hDlg
Case %WM_LButtonDown
If Cb.WParam = %MK_LBUTTON Then SendMessage hDlg, %WM_NCLButtonDown, %HTCaption, ByVal %Null ' force drag
Case %WM_Destroy
SetWindowLong hToolbar, %GWL_WNDPROC, OldProc 'un-subclass, restore original window procedure
End Select
End Function
Function NewProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case Msg
Case %WM_LButtonDown
If wParam = %MK_LBUTTON Then SendMessage hDlg, %WM_NCLButtonDown, %HTCaption, ByVal %Null ' force drag
End Select
Function = CallWindowProc(OldProc, hWnd, Msg, wParam, lParam)
End Function
'gbs_00811
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm