Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Win/Windows System Tray
Function:
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/Windows System Tray
This example is the version from Sun, 10th Dec 2016.
Project "Windows System Tray.rbp"
Class Window1 Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() if e.add then list.addrow "Added icon." else list.addrow "Failed to add icon." end if running=true End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() if e.Remove then list.addrow "Removed tray." else list.addrow "Failed removed tray." end if running=false End EventHandler
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
EventHandler Function MouseDown(X As Integer, Y As Integer) As Boolean dim c as color c=col if selectcolor(c,"Select color:") then col=c update if running then if e.modify then list.insertrow 0,"Modified icon" else list.insertrow 0,"Can't modify icon" end if end if refresh end if End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.foreColor=col g.fillrect 0,0,g.width,g.height End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control eBalloonTitle Inherits TextField
ControlInstance eBalloonTitle Inherits TextField
EventHandler Sub TextChange() e.BalloonTitle=eBalloonTitle.text End EventHandler
End Control
Control eBalloonText Inherits TextField
ControlInstance eBalloonText Inherits TextField
EventHandler Sub TextChange() e.BalloonText=eBalloonText.text End EventHandler
End Control
Control eTooltip Inherits TextField
ControlInstance eTooltip Inherits TextField
EventHandler Sub TextChange() e.Tooltip=eTooltip.text End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() if e.Modify then list.addrow "Changed tray." else list.addrow "Failed change tray." end if End EventHandler
End Control
EventHandler Sub Close() quit End EventHandler
EventHandler Sub Open() col=rgb(255,0,0) e=new MyWindowsSystemtray e.ID=12345678 e.Tooltip=eTooltip.text e.BalloonText=eBalloonText.text e.BalloonTitle=eBalloonTitle.text e.BalloonMode=0 update End EventHandler
Sub update() #if UsePicture dim p,m as picture const w=16 const h=16 p = new Picture(w,h,32) m = new Picture(w,h,32) p.graphics.foreColor=col p.graphics.filloval 0,0,w,h m.graphics.foreColor=&c00000 m.graphics.fillrect 0,0,w,h m.graphics.foreColor=&cFFFFFF m.graphics.filloval 0,0,w,h call e.SetIconPicture(p,m) #else call e.SetIconFile(WindowsFolderMBS.Child("explorer.exe"),1) #endif End Sub
Property Protected col As color
Property Protected e As MyWindowssystemtray
Property Protected running As boolean
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class MyWindowsSystemTray Inherits WindowsSystemTrayMBS
EventHandler Sub BalloonHide(id as integer, MouseX as integer, MouseY as integer) w "BalloonHide",id,Mousex,Mousey End EventHandler
EventHandler Sub BalloonShow(id as integer, MouseX as integer, MouseY as integer) w "BalloonShow",id,Mousex,Mousey End EventHandler
EventHandler Sub BalloonTimeout(id as integer, MouseX as integer, MouseY as integer) w "BalloonTimeout",id,Mousex,Mousey End EventHandler
EventHandler Sub BalloonUserClick(id as integer, MouseX as integer, MouseY as integer) w "BalloonUserClick",id,Mousex,Mousey End EventHandler
EventHandler Sub ContextMenu(id as integer, MouseX as integer, MouseY as integer) w "ContextMenu",id,Mousex,Mousey End EventHandler
EventHandler Sub KeySelected(id as integer, MouseX as integer, MouseY as integer) w "KeySelected",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseLeftButtonDoubleClick(id as integer, MouseX as integer, MouseY as integer) w "MouseLeftButtonDoubleClick",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseLeftButtonDown(id as integer, MouseX as integer, MouseY as integer) w "MouseLeftButtonDown",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseLeftButtonUp(id as integer, MouseX as integer, MouseY as integer) w "MouseLeftButtonUp",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseMiddleButtonDoubleClick(id as integer, MouseX as integer, MouseY as integer) w "MouseMiddleButtonDoubleClick",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseMiddleButtonDown(id as integer, MouseX as integer, MouseY as integer) w "MouseMiddleButtonDown",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseMiddleButtonUp(id as integer, MouseX as integer, MouseY as integer) w "MouseMiddleButtonUp",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseMove(id as integer, MouseX as integer, MouseY as integer) w "MouseMove",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseRightButtonDoubleClick(id as integer, MouseX as integer, MouseY as integer) w "MouseRightButtonDoubleClick",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseRightButtonDown(id as integer, MouseX as integer, MouseY as integer) w "MouseRightButtonDown",id,Mousex,Mousey End EventHandler
EventHandler Sub MouseRightButtonUp(id as integer, MouseX as integer, MouseY as integer) w "MouseRightButtonUp",id,Mousex,Mousey End EventHandler
EventHandler Sub PopupOpen(id as integer, MouseX as integer, MouseY as integer) w "PopupOpen",id,Mousex,Mousey End EventHandler
EventHandler Sub Selected(id as integer, MouseX as integer, MouseY as integer) w "Selected",id,Mousex,Mousey End EventHandler
Sub w(s as string,id as integer,x as integer, y as integer) window1.list.insertrow 0,s+" in System Tray Icon ID "+str(id)+" x: "+str(x)+" y: "+str(y) End Sub
End Class
Module Switches
Const UsePicture = true
End Module
Class App Inherits Application
EventHandler Sub Open() if TargetWin32 = false then MsgBox "This example is only for Windows." quit end if End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

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





Links
MBS Xojo PDF Plugins