Date: 02-16-2022
Return to Index
created by gbSnippets
'This code simulates drawing a free style line on a dialog, but it
'actually is creating multiple line controls instead (up to 1000, as written).
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
Global hDlg As DWord, X as Long, Y as Long, iCount As Long, OldLine As Long
Global Xold as Long, Yold as Long, iLine as Long, Iflag As Long, S as Long
Function PBMain() As Long
iLine = 1000 : S = 3
Dialog New Pixels, 0, "Line Test",300,300,400,400, %WS_SysMenu, 0 To hDlg
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case CB.Msg
Case %WM_LButtonDown
Xold = Lo(Word, CB.lParam) : Yold = Hi(Word, CB.lParam)
OldLine = iLine : Iflag = 1
Control Add Line, hDlg, iLine, "", Xold, Yold, S, S, %SS_BlackRect
Control Redraw hDlg, iLine
Case %WM_MouseMove
If Iflag Then
X = Lo(Word, CB.lParam) : Y = Hi(Word, CB.lParam)
Incr iLine
Control Add Line, hDlg, iLine, "", X, Y, S, S, %SS_BlackRect
Control Redraw hDlg, iLine
End If
Case %WM_LButtonUp
X = Lo(Word, CB.lParam) : Y = Hi(Word, CB.lParam) : Iflag = 0
Control Add Line, hDlg, iLine, "", X, Y, S, S, %SS_BlackRect
Control Redraw hDlg, iLine
End Select
End Function
'gbs_00418
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm