Verfasst: 05.06.2009 19:31
für welche pb version ist es denn geschrieben?
Ich benutz 4.10
Ich benutz 4.10
Code: Alles auswählen
;Shows a ProgressBar on a G15 (if available)
;If you don't own a G15 keyboard change to #False:
XIncludeFile "G15_Source.pb"
#HAS_G15_KEYBOARD = #True
Structure _G15_STATIC_VARS_
Device.l
Connection.l
ImageID.l
EndStructure
Procedure G15_Show_Progress(Progress, ProgramName.s = "")
;Progress goes from 0 to 100.
;If you send -1, Application will close connection to the G15
Protected ctx.lgLcdConnectContext, ctxo.lgLcdOpenContext
Protected InitMode
Static G15._G15_STATIC_VARS_
If Progress < -1
Progress = -1
ElseIf Progress > 100
Progress = 100
EndIf
If G15\Device = 0
;First Call!
If #HAS_G15_KEYBOARD
InitMode = #LGLCD_INIT_NORMAL; | #LGLCD_INIT_ADD_DISPLAY
Else
InitMode = #LGLCD_INIT_ONLY_DISPLAY
EndIf
If lgLcdInit(InitMode) = #ERROR_SUCCESS
ctx\appFriendlyName = @ProgramName
ctx\isPersistent = #False
ctx\isAutostartable = #False
If lgLcdConnect(@ctx) <> #ERROR_SUCCESS
lgLcdDeInit()
Else
ctxo\connection = ctx\connection
ctxo\index = 0
G15\Connection = ctx\connection
If lgLcdOpen(@ctxo) <> #ERROR_SUCCESS
lgLcdDisconnect(G15\Connection)
lgLcdDeInit()
Else
G15\Device = ctxo\Device
G15\ImageID = CreateImage(#PB_Any, #LGLCD_BMP_WIDTH, #LGLCD_BMP_HEIGHT, 8) ;<- Only 8Bit supported!
;Create RawPicture
StartDrawing(ImageOutput(G15\ImageID))
FillArea(0, 0, -1, $FFFFFF)
DrawText((#LGLCD_BMP_WIDTH - TextWidth("Loading " + ProgramName)) / 2, 5, "Loading " + ProgramName, 0)
Box(20, 30, Progress, 10, 0)
DrawText(125, 26, Str(Progress) + "%")
StopDrawing()
If lgLcdUpdateBitmap(G15\Device,G15\ImageID, LGLCD_ASYNC_UPDATE(#LGLCD_PRIORITY_ALERT)) = #ERROR_SUCCESS
lgLcdSetAsLCDForegroundApp(G15\Device, #LGLCD_LCD_FOREGROUND_APP_YES)
EndIf
EndIf
EndIf
EndIf
ElseIf Progress = -1
lgLcdClose(G15\Device)
lgLcdDisconnect(G15\Connection)
lgLcdDeInit()
G15\Device = 0
FreeImage(G15\ImageID)
ElseIf IsImage(G15\ImageID)
StartDrawing(ImageOutput(G15\ImageID))
Box(20, 30, Progress, 10, 0)
DrawText(125, 26, Str(Progress) + "%")
StopDrawing()
lgLcdUpdateBitmap(G15\Device, G15\ImageID, LGLCD_ASYNC_UPDATE(#LGLCD_PRIORITY_ALERT))
EndIf
EndProcedure
;-------------------------
;Example!!
Procedure main()
OpenWindow(0, 250, 250, 220, 44, "Progress Test...", #PB_Window_SystemMenu)
TextGadget(0, 10, 14, 200, 20, "Watch your Display", #PB_Text_Center)
Repeat
Select WaitWindowEvent(20)
Case #PB_Event_CloseWindow
G15_Show_Progress(-1)
Break
Case 0
If i < 101
G15_Show_Progress(i, "My Application")
i + 1
ElseIf i = 101
i = 102
SetGadgetText(0, "Application loaded. Ready to Rumble...")
EndIf
EndSelect
ForEver
EndProcedure
main()
Warum denn das?R4z0r1989 hat geschrieben:Ich benutz 4.10
Und wieso steht dann der Button in deiner Signatur auf 3.90?R4z0r1989 hat geschrieben:Ich benutz 4.10