Code
; PureBasic Visual Designer v3.95 build 1485 (PB4Code)
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Image_0
EndEnumeration
;- Image Plugins
;- Image Globals
Global Image0
;- Catch Images
Image0 = CreateImage(#PB_Any, 160, 160)
If StartDrawing(ImageOutput(Image0))
Box(0, 0, 160, 160, $FFFFFF)
StopDrawing()
EndIf
Procedure.l MouseOverGadget(WindowID_L.l, GadgetID_L.l) ; returns 1, if the mouse is over the gadget
Back_L.l
wx = WindowMouseX(#Window_0)
wy = WindowMouseY(#Window_0)
gx = GadgetX(GadgetID_L)
gy = GadgetY(GadgetID_L)
If wx > -1 And wy > -1
If wx- gx > 0 And wx- gx <= GadgetWidth(GadgetID_L)
If wy- gy > 0 And wy- gy <= GadgetHeight(GadgetID_L)
Back_L = 1
EndIf
EndIf
EndIf
ProcedureReturn Back_L
EndProcedure
Procedure Open_Window_0()
LBtnDwn_L.l
If OpenWindow(#Window_0, 216, 0, 579, 493, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ImageGadget(#Image_0, 200, 80, 160, 160, ImageID(Image0), #PB_Image_Border)
Repeat ; Start of the event loop
Event = WindowEvent()
WindowID = EventWindow() ; The Window where the event is generated, can be used in the gadget procedures
GadgetID = EventGadget() ; Is it a gadget event?
EventType = EventType() ; The event type
If GetSystemMetrics_(#SM_SWAPBUTTON)
LBtnDwn_L = GetAsyncKeyState_(#VK_RBUTTON) & $8000
Else
LBtnDwn_L = GetAsyncKeyState_(#VK_LBUTTON) & $8000
EndIf
If GadgetID = #Image_0
If MouseOverGadget(#Window_0, #Image_0)
If LBtnDwn_L
If StartDrawing(ImageOutput(Image0))
wx = WindowMouseX(#Window_0)
wy = WindowMouseY(#Window_0)
gx = GadgetX(#Image_0)
gy = GadgetY(#Image_0)
Circle(wx- gx, wy- gy, 3, $000000)
StopDrawing()
EndIf
SetGadgetState(#Image_0, ImageID(Image0))
EndIf
EndIf
EndIf
Delay(1)
Until Event = #PB_Event_CloseWindow ; End of the event loop
EndIf
EndIf
EndProcedure
Open_Window_0()
End