Platforms to show: All Mac Windows Linux Cross-Platform

/Win/Windows System Tray with Icon file/Windows System Tray with Icon file


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 with Icon file/Windows System Tray with Icon file

This example is the version from Thu, 6th Apr 2016.

Project "Windows System Tray with Icon file.xojo_binary_project"
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
Function FindFile(name as string) As FolderItem // Look for file in parent folders from executable on dim parent as FolderItem = app.ExecutableFile.Parent while parent<>Nil dim file as FolderItem = parent.Child(name) if file<>Nil and file.Exists then Return file end if parent = parent.Parent wend End Function
Sub update() // copy icon to app folder call e.SetIconFile(FindFile("someicon.ico"),0) 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
Class App Inherits Application
End Class
End Project

See also:

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


The biggest plugin in space...