Battery Power
Posted: Sun Aug 12, 2007 2:39 am

You might have neat code but using a GOTO is not very neat.michaeled314 wrote: HA! HA! I'm a neater coder than any of you guys on this forum
Code: Select all
Procedure Refresh(timeout)
Repeat
powerpolicyglobal.GLOBAL_POWER_POLICY
powerpolicy.POWER_POLICY
syspowerstat.SYSTEM_POWER_STATUS
If GetSystemPowerStatus_(syspowerstat)
Select syspowerstat\ACLineStatus
Case 0
SetGadgetText(0,"You are currently on Battery Power")
Case 1
SetGadgetText(0,"You are currently on AC Power")
EndSelect
SetGadgetText(1,Str(syspowerstat\BatteryLifePercent)+"%")
Select syspowerstat\BatteryFlag
Case 1
SetGadgetColor(1,#PB_Gadget_FrontColor,RGB(0,0,0))
Case 2
SetGadgetColor(1,#PB_Gadget_FrontColor,RGB(0,255,0))
Case 4
SetGadgetColor(1,#PB_Gadget_FrontColor,RGB(0,0,255))
EndSelect
EndIf
Delay(1000)
ForEver
EndProcedure
If OpenWindow(0,0,0,300,500,"Power Meter",#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
hWnd = WindowID(0)
hDC = GetDC_(hWnd)
If Not CreateGadgetList(hWnd)
End
EndIf
TextGadget(0,20,20,270,20,"",#PB_Text_Center)
TextGadget(1,20,40,270,20,"",#PB_Text_Center)
If CreateMenu(0,hWnd)
MenuTitle("Power")
MenuItem(0,"Settings")
EndIf
CreateThread(@Refresh(),timeout)
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Menu
Menu = EventMenu()
Select Menu
Case 0
CreateThread(@PowerPoliciesWin(),hWnd)
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
Have a look at this post : http://www.purebasic.fr/english/viewtopic.php?t=25132dobro wrote:hum structure no found
"GLOBAL_POWER_POLICY"
si on te le demande, tu dira que t'en sais rienKaeru Gaman wrote:what is this...a zombie ritual?
c'est ptete parceque j'ai besoin de ce code, t'y avais pas pensé ? .... m'étonne pas ...or why exhuming an almost two years buried thread...