Date: 02-16-2022
Return to Index
created by gbSnippets
'The wParam/lParam message parameters are often used to pass two numeric (Integer)
'values - one in the lower 2 bytes and another in the upper 2 bytes of either wParam
'or lParam, both of which are 4 bytes.
'LoWord/HiWord functions are used to extract the lower/upper integer values
'MAK is used to combine two integer values into a Long (or DWord), suitable for assignment
'as wParam/lParam message arguments.
'Primary Code:
LoWord% = Lo(WORD, wParam) 'extract value from lower 2 bytes
HiWord% = Hi(WORD, wParam) 'extract value from upper 2 bytes
iResult& = Mak(DWord, LoWord%, HiWord%) 'combine two values into a DWord
'Compilable Example: (Jose Includes)
'%WM_MouseMove is sent whenever the mouse moves over the dialog's client area. lParam has
'the x position of the cursor in its low-order word, and the y position in the high-order word
'both are in client area coordinates
'This example use Lo/Hi to extract the x/y coordinates, which are displayed as the dialog caption.
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg As DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,300,150, %WS_OverlappedWindow To hDlg
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local x as Long, y as Long, iReturn as Long
Select Case CB.Msg
Case %WM_MouseMove
x = Lo(Word,CB.lParam) : y = Hi(Word, CB.lParam)
Dialog Set Text hDlg, "Mouse Coordinates: " + Str$(x) + " : " + Str$(y)
End Select
End Function
'gbs_00077
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm