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"
Enum Equates Singular
IDC_Graphic = 500
End Enum
Global hDlg As Dword, LastX, LastY As Long
Function PBMain() As Long
Dialog New Pixels, 0, "FreeStyle Line Drawing",300,300,300,300, %WS_OverlappedWindow To hDlg
Control Add Graphic, hDlg, %IDC_Graphic,"", 0,0,300,300
Graphic Attach hDlg, %IDC_Graphic
Graphic Width 10
Graphic Set Mix %R2_CopyPen
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local x,y,i,j As Long
Select Case Cb.Msg
Case %WM_InitDialog
LastX = -1
Case %WM_LButtonDown
SetCapture hDlg 'start capturing, so can detect LButtonUp when it occurs
Case %WM_MouseMove
If GetCapture() = hDlg Then 'app has capture 'why?
x = Lo(Integer,Cb.LParam)
y = Hi(Integer,Cb.LParam)
If LastX = -1 Then LastX = x : LastY = y
Graphic Line (LastX,LastY)-(x,y), %Red
LastX = x : LastY = y
End If
Case %WM_LButtonUp
ReleaseCapture
LastX = -1
End Select
End Function
'gbs_01285
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm