imagegadget. das problemlöst so einiges.
Code: Alles auswählen
; PB4.10
; PureBasic Visual Designer v3.95 build 1485 (PB4Code)
;- Window Constants
;
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#Button_0
#Button_1
#Button_2
#Button_3
#Button_schratig
#Image_0
#Button_4
#Text_0
#Image
EndEnumeration
;- Image Plugins
;- Image Globals
;- Catch Images
CreateImage(#Image,100,100)
StartDrawing(ImageOutput(#Image))
Box(0,0,100,100,RGB(64,200,222))
For z=0 To 5000
Plot(Random(200),Random(200),RGB(Random(128)+128,Random(128)+128,Random(128)+128))
Next z
StopDrawing()
;SetGadgetState(#Image_0,Image0)
;- Images
If OpenWindow(#Window_0, 216, 0, 900, 900, "New window ( 0 )", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ImageGadget(#Image_0, 60, 100, 100, 70, ImageID(#Image),#PB_Image_Border)
DisableGadget(#Image_0,1)
ButtonGadget(#Button_0, 100, 40, 70, 30, "1 an")
ButtonGadget(#Button_1, 170, 40, 60, 30, "1&&3 aus")
ButtonGadget(#Button_2, 230, 40, 80, 30, "7 Dialog")
ButtonGadget(#Button_3, 310, 40, 120, 30, "3 Windowdrawing an")
ButtonGadget(#Button_schratig, 430, 40, 120, 30, "schratig an")
TextGadget(#Text_0, 170, 90, 420, 80, "schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel schnasel ")
ButtonGadget(#Button_4, 210, 190, 220, 60, "ENDE")
EndIf
EndIf
Repeat ; Start of the event loop
If eumel
StartDrawing(ImageOutput(#Image))
Box(0,0,100,100,RGB(64,200,222))
For z=0 To 500
x=Random(100)
y=Random(100)
Box(x,y,5,5,RGB(Random(128)+128,Random(128)+128,Random(128)+128))
Next z
StopDrawing()
SetGadgetState(#Image_0,ImageID(#Image))
EndIf
Event = WaitWindowEvent(eumel) ; This line waits until an event is received from Windows
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 event<>0 ; bei Events
SetGadgetText(#Text_0,Str(event)) ;Ausgabe des Events
If erwin ;so es soll
StartDrawing(WindowOutput(#window_0)) ;wird das Bild auf
DrawImage(ImageID(#Image),0,0,100,100) ;das Window gemalt
DrawText(0,0,"ich zappel nur für Events")
StopDrawing()
EndIf
EndIf
;You can place code here, and use the result as parameters for the procedures
If Event = #PB_Event_Gadget
If GadgetID = #Button_0
eumel=20
ElseIf GadgetID = #Button_schratig
If GetGadgetText(#Button_schratig)="schratig an"
SetGadgetText(#Button_schratig,"schratig aus")
Else
SetGadgetText(#Button_schratig,"schratig an")
EndIf
ElseIf GadgetID = #Button_1
eumel=0
If erwin ;so es soll
erwin=0 ;soll es nicht mehr :)
StartDrawing(WindowOutput(#Window_0)) ;letzte Ausgabe
DrawText(0,0,"refresh? ..selber machen")
Delay(1000)
DrawText(20,0,"AaH .. Idee !!")
Delay(500)
StopDrawing()
;es folgt eine etwas ungewöhnliche refreshlösung
y=WindowY(#window_0)
If GetGadgetText(#Button_schratig)="schratig an"
While WindowHeight(#window_0)+WindowY(#window_0)>0
ResizeWindow(#window_0,#PB_Ignore,WindowY(#window_0)-1,#PB_Ignore,#PB_Ignore)
While WindowEvent():Wend
Delay(1)
Wend
While WindowY(#window_0)<y
ResizeWindow(#window_0,#PB_Ignore,WindowY(#window_0)+1,#PB_Ignore,#PB_Ignore)
While WindowEvent():Wend
Delay(2)
Wend
Else
ResizeWindow(#window_0,#PB_Ignore,-WindowHeight(#window_0),#PB_Ignore,#PB_Ignore)
ResizeWindow(#window_0,#PB_Ignore,y,#PB_Ignore,#PB_Ignore)
EndIf
EndIf
ElseIf GadgetID = #Button_2
OpenFileRequester("Eumel?","redraw checken","*.*",0)
ElseIf GadgetID = #Button_3
erwin=1
ElseIf GadgetID = #Image_0
ElseIf GadgetID = #Button_4
quit=1
EndIf
EndIf
Until Event = #PB_Event_CloseWindow Or quit=1; End of the event loop
End