Date: 02-16-2022
Return to Index
created by gbSnippets
'Compiler Comments:
'This code is written to compile in PBWin10. To compile in PBWin9, split pt
'into pt.x and pt.y as arguments wherever the ChildWindowFromPoint() API is used (1 place).
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_GraphicA = 500 : %IDC_GraphicB = 501
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "not captured",900,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Graphic, hDlg, %IDC_GraphicA,"", 50,10,75,75, %WS_Visible Or %WS_Border
Control Add Graphic, hDlg, %IDC_GraphicB,"", 50,95,75,75, %WS_Visible Or %WS_Border
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local pt As Point, x,y As Long
Static dx,dy,ChildID As Long
Select Case Cb.Msg
Case %WM_MouseMove 'posted to window that has captured the mouse
If (Cb.WParam And %MK_LBUTTON) And ChildID Then
Control Set Loc hDlg, ChildID, Lo(Word,Cb.LParam)+dx, Hi(Word,Cb.LParam)+dy
End If
Case %WM_LButtonDown 'posted to window that has captured the mouse
pt.x = Lo(Word,Cb.LParam) : pt.y = Hi(Word,Cb.LParam)
ChildID = GetDlgCtrlID(ChildWindowFromPoint(hDlg, pt))
Control Get Loc hDlg, ChildID To x,y
dx = x - Lo(Word, Cb.LParam)
dy = y - Hi(Word, Cb.LParam)
Case %WM_LButtonUp 'posted to window that has captured the mouse
End Select
End Function
'gbs_00177
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm