Date: 02-16-2022
Return to Index
created by gbSnippets
'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, "Drag Control Test",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 ddx,ddy,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)+ddx, Hi(Word,Cb.LParam)+ddy
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
ddx = x - Lo(Word, Cb.LParam)
ddy = y - Hi(Word, Cb.LParam)
Case %WM_LButtonUp 'posted to window that has captured the mouse
End Select
End Function
'gbs_00823
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm