does not change the color of the pen
Code: Select all
Procedure DrawSelector( Window,MouseX,MouseY,State,Pen =3,PenColor =$E2B256 )
Static .i lastX, lastY, MoveMouseX, MoveMouseY
Protected hDC
If State
hDC = StartDrawing(WindowOutput(Window))
If hDC
DrawingMode(#PB_2DDrawing_Outlined|#PB_2DDrawing_XOr)
Box(lastX, lastY, MoveMouseX-lastX, MoveMouseY-lastY,PenColor)
lastX = MouseX :MoveMouseX = WindowMouseX(Window)
lastY = MouseY :MoveMouseY = WindowMouseY(Window)
Box( lastX, lastY, MoveMouseX-lastX, MoveMouseY-lastY,PenColor)
StopDrawing()
Delay(50)
ProcedureReturn State
EndIf
EndIf
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
If OpenWindow(1,0,0,750,500,"Rectangle Selection Demo",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #WM_LBUTTONDOWN :active=1
Define mx = WindowMouseX(1)
Define my = WindowMouseY(1)
Case #WM_MOUSEMOVE :DrawSelector(1,mx,my,active)
Case #WM_LBUTTONUP :active =0
EndSelect
ForEver
EndIf
CompilerEndIfCode: Select all
Procedure DrawSelector( Window,MouseX,MouseY,State,Pen =3,PenColor =$E2B256 )
Static .i lastX, lastY, MoveMouseX, MoveMouseY
Protected hDC
If State
hDC = StartDrawing(WindowOutput(Window))
If hDC
DrawingMode(#PB_2DDrawing_Outlined) :SetROP2_(hdc, #R2_NOTXORPEN)
Box(lastX, lastY, MoveMouseX-lastX, MoveMouseY-lastY,PenColor)
lastX = MouseX :MoveMouseX = WindowMouseX(Window)
lastY = MouseY :MoveMouseY = WindowMouseY(Window)
Box( lastX, lastY, MoveMouseX-lastX, MoveMouseY-lastY,PenColor)
StopDrawing()
Delay(50)
ProcedureReturn State
EndIf
EndIf
EndProcedure
CompilerIf #PB_Compiler_IsMainFile
If OpenWindow(1,0,0,750,500,"Rectangle Selection Demo",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #WM_LBUTTONDOWN :active=1
Define mx = WindowMouseX(1)
Define my = WindowMouseY(1)
Case #WM_MOUSEMOVE :DrawSelector(1,mx,my,active)
Case #WM_LBUTTONUP :active =0
EndSelect
ForEver
EndIf
CompilerEndIf


