Und in der Kategorie "Clock" findest du einen nützlichen Code von Danilo.
Code: Alles auswählen
EnableExplicit
Define EventID
Procedure.f DSin(angle_in_degree.f)
; returns Sinus of 'angle in degree
ProcedureReturn Sin(angle_in_degree*0.01745329)
EndProcedure
Procedure.f DCos(angle_in_degree.f)
; returns CoSinus of 'angle in degree
ProcedureReturn Cos(angle_in_degree*0.01745329)
EndProcedure
Procedure Lin(hDC,x,y,x1,y1,width,Color)
Protected pen
Protected hPenOld
pen=CreatePen_(#PS_SOLID,width,Color) ; You can also change the style with #Ps_dash, #Ps_dot, #Ps_dashdotdot, but only when the pen width equals 1.
hPenOld=SelectObject_(hDC,pen)
MoveToEx_(hDC,x,y,0):LineTo_(hDC,x1,y1)
DeleteObject_(SelectObject_(hDC,hPenOld))
EndProcedure
Procedure UpdateDisplay()
Protected date = Date()
Protected second = Second(date)
Protected minute = Minute(date)
Protected sec.f = (180-second*6)
Protected min.f = (180-minute*6);-second/10
Protected std.f = (180-Hour(date)*30)-minute/2
Protected hDC
hDC = StartDrawing(ImageOutput(1))
If hDC
Circle(125,125,95,$999999)
Lin(hDC,125,125,125+DSin(std)*70,125+DCos(std)*70,10,0) ; hours
Lin(hDC,125,125,125+DSin(min)*80,125+DCos(min)*80, 4,0) ; minutes
LineXY( 125,125,125+DSin(sec)*90,125+DCos(sec)*90, 0) ; seconds
StopDrawing()
EndIf
SetGadgetState(1,ImageID(1))
EndProcedure
Procedure InitImage()
Protected img = CreateImage(1,250,250)
Protected ForeGround
Protected a
Protected sin.f
Protected cos.f
Protected b
If img = 0
MessageRequester("ERROR","Cant create image!",#MB_ICONERROR):End
EndIf
LoadFont(1,"Arial",14)
If StartDrawing(ImageOutput(1))
Box(0,0,250,250,GetSysColor_(#COLOR_BTNFACE))
Circle(125,125,100,$999999)
ForeGround = GetSysColor_(#COLOR_BTNTEXT)
FrontColor(RGB(Red(ForeGround),Green(ForeGround),Blue(ForeGround)))
DrawingMode(1)
DrawingFont(FontID(1))
DrawText(125-TextWidth("12")/2,4,"12")
DrawText(10,115,"9")
DrawText(230,115,"3")
DrawText(125-TextWidth("6")/2,225,"6")
For a = 0 To 360 Step 6
sin.f = DSin(a)
cos.f = DCos(a)
Plot(125+sin*99,125+cos*99,0)
If a % 10 = 0
For b = 2 To 0 Step -1
Plot(125+sin*(98-b),125+cos*(98-b),0)
Next b
EndIf
Next a
StopDrawing()
EndIf
ProcedureReturn img
EndProcedure
If OpenWindow(0,0,0,500,400,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ImageGadget(1,10,10,250,250,InitImage())
UpdateDisplay()
AddWindowTimer(0, 123, 1000)
Repeat
EventID=WaitWindowEvent()
If EventID=#PB_Event_Timer And EventTimer() = 123
UpdateDisplay()
EndIf
If EventID = #PB_Event_CloseWindow
End
EndIf
ForEver
EndIf