Hier der neue "bessere" Code:
Code: Alles auswählen
; PureBasic Visual Designer v3.95 build 1485 (PB4Code)
;- Window Constants
;
Enumeration
#Window_main
EndEnumeration
;- Gadget Constants
;
Enumeration
#Image_gadget
#Button_Neu
#Button_Speichern
#image1
EndEnumeration
Structure Punkt
x.l
y.l
EndStructure
MausPos.Punkt
CreateImage(#image1, 500, 500)
StartDrawing(ImageOutput(#image1))
Box(0,0 , 500, 500, RGB(255,255,0))
StopDrawing()
Procedure Open_Window_main()
If OpenWindow(#Window_main, 216, 0, 834, 581, "imager", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_main))
ImageGadget(#Image_gadget, 40, 40, 520, 580, ImageID(#image1))
ButtonGadget(#Button_Neu, 670, 460, 140, 40, "Neu")
ButtonGadget(#Button_Speichern, 670, 520, 140, 40, "Speichern")
EndIf
EndIf
EndProcedure
Open_window_main()
Repeat
event= WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case #image_gadget
Select EventType()
Case #PB_EventType_LeftClick
MausPos\x = WindowMouseX(#window_main)
MausPos\y = WindowMouseY(#window_main)
StartDrawing(ImageOutput(#image1))
Box(MausPos\x - 40, MausPos\y - 40, 10, 10, RGB(0,0,255))
StopDrawing()
SetGadgetState(#image_gadget, ImageID(#image1))
EndSelect
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow

