Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Win Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/WindowsPowerState
This example is the version from Sun, 9th Sep 2023.
Project "WindowsPowerState.xojo_binary_project"
FileTypes
Filetype Text
End FileTypes
Class MainWindow Inherits Window
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
EventHandler Sub Open()
c=New MyWindowsPowerState
c.List = listbox1
c.ListenForBatteryCapacityChanged
c.ListenForLidSwitchStateChanged
c.ListenForPowerSourceChanged
c.ListenForSuspendResumeNotification
End EventHandler
Property Protected c As MyWindowsPowerState
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu5 = ""
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu4 = ""
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = ""
End MenuBar
Class App Inherits Application
End Class
Class MyWindowsPowerState Inherits WindowsPowerStateMBS
EventHandler Sub BatteryCapacityChanged(Percentage as Integer)
w "BatteryCapacityChanged: "+Percentage.ToString
End EventHandler
EventHandler Sub BatteryLow()
w "BatteryLow"
End EventHandler
EventHandler Sub LidSwitchStateChanged(LidState as Integer)
w "LidSwitchStateChanged: "+LidState.ToString
End EventHandler
EventHandler Sub OEMEvent(eventcode as integer)
w "OEMEvent "+hex(eventcode)
End EventHandler
EventHandler Sub PowerSettingChange(data as MemoryBlock)
End EventHandler
EventHandler Sub PowerSourceChanged(power as Integer)
w "PowerSourceChanged: "+Power.ToString
End EventHandler
EventHandler Sub PowerStatusChange()
w "PowerStatusChange"
End EventHandler
EventHandler Function QueryStandby(PromptUser as boolean) As boolean
// deprecated in Windows?
w "QueryStandby"
End EventHandler
EventHandler Sub QueryStandbyFailed()
// deprecated in Windows?
w "QueryStandbyFailed"
End EventHandler
EventHandler Function QuerySuspend(PromptUser as boolean) As boolean
w "QuerySuspend"
End EventHandler
EventHandler Sub QuerySuspendFailed()
w "QuerySuspendFailed"
End EventHandler
EventHandler Sub ResumeAutomatic()
w "ResumeAutomatic"
End EventHandler
EventHandler Sub ResumeCritical()
w "ResumeCritical"
End EventHandler
EventHandler Sub ResumeStandby()
// deprecated in Windows?
w "ResumeStandby"
End EventHandler
EventHandler Sub ResumeSuspend()
w "ResumeSuspend"
End EventHandler
EventHandler Sub Standby()
// deprecated in Windows?
w "Standby"
End EventHandler
EventHandler Sub Suspend()
w "Suspend"
End EventHandler
Private Sub w(w as string)
Dim d As New date
Dim s As String = d.LongTime+": "+w
System.DebugLog w
list.AddRow s
End Sub
Property list As listbox
End Class
End Project
The items on this page are in the following plugins: MBS Win Plugin.