Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

Required plugins for this example: MBS Util Plugin, MBS Win Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/Notification
This example is the version from Sun, 16th Aug 2014.
Project "Notification.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() if not TargetWin32 then MsgBox "This example is only for Windows." end if End EventHandler
End Class
Class MainWindow Inherits Window
Control ListenButton Inherits PushButton
ControlInstance ListenButton Inherits PushButton
EventHandler Sub Action() if w.ListenForMessage(TextField1.text) then List.InsertRow 0, "Listening for "+TextField1.Text else List.InsertRow 0, "Failed to listening for "+TextField1.Text end if End EventHandler
End Control
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
Control StopListening Inherits PushButton
ControlInstance StopListening Inherits PushButton
EventHandler Sub Action() if w.StopListeningForMessage(TextField1.text) then List.InsertRow 0, "Stopped listening for "+TextField1.Text else List.InsertRow 0, "Failed to stop listening for "+TextField1.Text end if End EventHandler
End Control
Control SendButton Inherits PushButton
ControlInstance SendButton Inherits PushButton
EventHandler Sub Action() dim v1,v2 as integer v1 = val(TextField2.text) v2 = val(TextField3.text) if w.SendMessage(TextField1.text, v1, v2) then List.InsertRow 0, "Sent message "+TextField1.Text else List.InsertRow 0, "Failed to send message "+TextField1.Text end if End EventHandler
End Control
Control list Inherits Listbox
ControlInstance list Inherits Listbox
End Control
Control TextField2 Inherits TextField
ControlInstance TextField2 Inherits TextField
End Control
Control TextField3 Inherits TextField
ControlInstance TextField3 Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
EventHandler Sub Open() w = new MyWinNotification // also listen for time changes and app switches const WM_DISPLAYCHANGE = &h7E const WM_TIMECHANGE = &h001E const WM_ACTIVATEAPP = &h1C const WM_DEVICECHANGE = &h0219 call w.ListenForMessage WM_TIMECHANGE call w.ListenForMessage WM_ACTIVATEAPP call w.ListenForMessage WM_DISPLAYCHANGE call w.ListenForMessage WM_DEVICECHANGE End EventHandler
Property w As MyWinNotification
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Datei"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyWinNotification Inherits WinNotificationMBS
EventHandler Sub GotNotification(Message as Integer, Name as string, Value1 as Integer, Value2 as Integer) const WM_TIMECHANGE = &h001E const WM_ACTIVATEAPP = &h1C const WM_DISPLAYCHANGE = &h7E const WM_DEVICECHANGE = &h0219 Select case Message case WM_TIMECHANGE Mainwindow.list.InsertRow 0, "System time changed." case WM_ACTIVATEAPP Mainwindow.list.InsertRow 0, "App switched." case WM_DISPLAYCHANGE Mainwindow.list.InsertRow 0, "Display Switched." // http://msdn.microsoft.com/de-de/library/windows/desktop/dd145210(v=vs.85).aspx // value1 = wParam, value2 = LParam Mainwindow.list.InsertRow 1, "New bit depth: "+str(value1) Mainwindow.list.InsertRow 2, "New width: "+str(LoWordMBS(value2)) Mainwindow.list.InsertRow 3, "New height: "+str(HiWordMBS(value2)) case WM_DEVICECHANGE Mainwindow.list.InsertRow 0, "Drive Changed." // http://msdn.microsoft.com/en-us/library/windows/desktop/aa363480(v=vs.85).aspx const DBT_DEVICEARRIVAL = &h8000 // system detected a new device const DBT_DEVICEQUERYREMOVE = &h8001 // wants to remove, may fail const DBT_DEVICEQUERYREMOVEFAILED = &h8002 // removal aborted const DBT_DEVICEREMOVEPENDING = &h8003 // about to remove, still avail. const DBT_DEVICEREMOVECOMPLETE = &h8004 // device is gone const DBT_DEVICETYPESPECIFIC = &h8005 // type specific event Select case Value1 case DBT_DEVICEARRIVAL Mainwindow.list.InsertRow 1, "system detected a new device" case DBT_DEVICEQUERYREMOVE Mainwindow.list.InsertRow 1, "wants to remove, may fail" case DBT_DEVICEQUERYREMOVEFAILED Mainwindow.list.InsertRow 1, "removal aborted" case DBT_DEVICEREMOVEPENDING Mainwindow.list.InsertRow 1, "about to remove, still avail." case DBT_DEVICEREMOVECOMPLETE Mainwindow.list.InsertRow 1, "device is gone" case DBT_DEVICETYPESPECIFIC Mainwindow.list.InsertRow 1, "type specific event" end Select else Mainwindow.list.InsertRow 0, name+": "+str(value1)+", "+str(value2) end Select End EventHandler
End Class
End Project

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Win Plugin.

MBS Xojo Chart Plugins