Date: 02-16-2022
Return to Index
created by gbSnippets
'When an event occurs Windows sends a message to the Dialog CallBack Function.
'The CB functions are used to easily retrieve information about the message.
'These CB functions can only be used within a CallBack Function. Special CB
'functions are provided for WM_Command and WM_Notify messages.
'CallBack functions in Windows have a standard set of four implied, standard message parameters.
Function DlgCallback(ByVal hDlg AS DWord, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
'Here is the content of the WM_Command and WM_Notify messages.
'Message wParam lParam
WM_Notify Control ID pointer to Nmhdr structure
WM_Command Lo-Control ID Control Handle
Hi-Notification Msg
'And here's a list of what's provided with CB - generic information on all
'messages plus specific information on WM_Command and WM_Notify messages.
Generic WM_Command WM_Notify
CB.Hndl CB.Ctl (Lo wParam) CB.Nmcode (notification Message)
CB.Msg CB.Ctlmsg (Hi wParam) CB.Nmhdr (pointer to structure)
CB.wParam CB.Nmhdr$
CB.lParam CB.Nmhwnd (Control Handle)
CB.NmID (Control ID)
'Here are descriptions of each of the various CB values.
'Generic CallBack Functions
CB.Hndl 'Window handle of the parent dialog
CB.Msg '%WM_COMMAND, %WM_NOTIFY, etc.
CB.wParam 'Message-dependent value.
CB.lParam 'Message-dependent value.
'%WM_COMMAND
'These CB values are only available when a %WM_Command message is received
CB.Ctl 'returns the Id number of the control. Is set to the low-order word of the wParam parameter. Lo(WORD, wParam)
CB.Ctlmsg 'returns the specific control message of the event which occurred. Is sent as the high-order word of the wParam parameter. Hi(WORD, wParam)
'%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 NMTOOLTIPSCREATED
'gbs_00007
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm