Date: 02-16-2022
Return to Index
created by gbSnippets
'%WM_NOTIFY
'These CB values are only valid when a %WM_Notify message is received
CB.Nmcode 'returns the specific notification message of the event which occurred.
CB.Nmhdr 'returns the address (a ) to the Nmhdr UDT, defined below.
CB.Nmhdr$ 'returns the contents of the Nmhdr UDT as a dynamic string.
CB.Nmhwnd 'returns the handle of the control which sent this message.
CB.NmID 'returns the Id number assigned to this Control.
'NMHDR Type declaration
Type Nmhdr hwndFrom as DWord
hWndFrom As DWord 'Handle of the control sending the message idfrom as Dword
IDFrom As DWord ' Identifier of the control sending the message code as Long
Code As Long ' Notification code
End Type
'The following list of notification messages require an extended version of the NM structure.
'However, all NM structures begin with an Nmhdr UDT, so the pointer returned here is always accurate.
%NM_CLICK NMMOUSE
%NM_RCLICK NMMOUSE
%NM_NCHITTEST NMMOUSE
%NM_KEYDOWN NMKEY
%NM_SETCURSOR NMMOUSE
%NM_CHAR NMCHAR
%NM_TOOLTIPSCREATED NMTOOLTIPSCREATE
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "commctrl.inc"
#Include "Win32API.inc"
%IDC_Toolbar = 500
Global hDlg, hToolbar As Dword 'main dialog handle
Global Flag, OldProc, MostRecentButton 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(GetDlgItem(hDlg, %IDC_Toolbar), %GWL_WndProc, CodePtr(NewProc)) 'subclass a control
Case %WM_Destroy
SetWindowLong hToolbar, %GWL_WNDPROC, OldProc 'un-subclass, restore original window procedure
Case %WM_Command
Select Case Cb.Ctl
Case 200 : MostRecentButton = 200 'toolbar button of interest
Case 201 : MostRecentButton = 201 'toolbar button of interest
End Select
End Select
End Function
Function NewProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Local iReturn As Long
Select Case Msg
Case %WM_LButtonDblClk
If MostRecentButton Then ? Str$(MostRecentButton) : MostRecentButton = 0
End Select
Function = CallWindowProc(OldProc, hWnd, Msg, wParam, lParam)
End Function
'gbs_00811
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm