{"id":618,"date":"2010-12-14T20:20:05","date_gmt":"2010-12-15T01:20:05","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=618"},"modified":"2021-03-10T18:35:41","modified_gmt":"2021-03-10T23:35:41","slug":"powerbuilder-application-icon-in-the-system-tray","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-application-icon-in-the-system-tray\/","title":{"rendered":"PowerBuilder &#8211; Application Icon in the System Tray"},"content":{"rendered":"<p>One challenge for Powerbuilder developers today is the lack of current information\/programming tips relating to more current (10 and above) versions. This also applies to Windows versions as well. There are a variety of different solutions to having an application icon in the System Tray but almost without exception they relate to Windows 95\/98 primarily. One of the best examples, called Icontray, can be found on the Roland Smith&#8217;s website <a href=\"https:\/\/www.topwizprogramming.com\/freecode_icontray.html\">TopWizProgramming.com<\/a>.<br \/>\n<a href=\"http:\/\/anvil-of-time.com\/wordpress\/wp-content\/uploads\/2010\/12\/systray.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-620 size-full\" title=\"systray\" src=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systray.png\" alt=\"\" width=\"197\" height=\"104\" srcset=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systray.png 197w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systray-150x79.png 150w\" sizes=\"(max-width: 197px) 100vw, 197px\" \/><\/a><br \/>\nThis example launches the application and minimizes it to the system tray. Right clicking on the icon opens an options window. This window will open based on the location of the system tray on your desktop. It has only been tested on a single monitor machine so there may be the need to tweak it if multiple monitor configuration is used. On the options window is a datawindow which gets populated upon opening. This demonstrates how you can add or remove options based on some condition in the main application. The popup default is to close after ten seconds. You have the option to &#8216;pin&#8217; the window so it always stays open.<br \/>\n<a href=\"http:\/\/anvil-of-time.com\/wordpress\/wp-content\/uploads\/2010\/12\/systrayoptions.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-621 size-full\" title=\"systrayoptions\" src=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systrayoptions.png\" alt=\"\" width=\"168\" height=\"167\" srcset=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systrayoptions.png 168w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systrayoptions-150x150.png 150w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systrayoptions-100x100.png 100w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systrayoptions-120x120.png 120w\" sizes=\"(max-width: 168px) 100vw, 168px\" \/><\/a><br \/>\nAlmost all of the system tray functionality is done via a series of API calls encapsulated within an nvo. These include:<br \/>\n<strong>Shell_NotifyIcon<\/strong> &#8211; adds, modifies, or removes the icon (ANSI and Unicode versions exist). This API uses a structure called NOTIFYICONDATA which passes the various elements and commands needed.<br \/>\nIn this sample the NOTIFYICONDATA structure is set up to return the &#8216;callback&#8217; message mapped to the PBM_CUSTOM01 event on the window associated with the icon. This has been mapped to a window event called &#8216;trayevent&#8217;. The callback itself takes the form of various events such as &#8216;left clicked&#8217;, &#8216;right clicked&#8217;, etc. If you are already using PBM_CUSTOM01 for something else, you can use any of the other PBM_CUSTOM events (they are numbered 1024 to 1098 for events 01 through 75).<\/p>\n<p><strong>LoadImage<\/strong> &#8211; loads an icon, cursor, or bitmap and returns a handle to it (ANSI and Unicode versions exist). These can be loaded from files themselves or can be extracted from .dlls they have been included in.<br \/>\n<strong>FindWindow<\/strong> &#8211; returns a handle to the System Tray window.<br \/>\n<strong>GetWindowRect<\/strong> &#8211; populates a structure with the coordinates of a window.<br \/>\nThese two methods tell us where the system tray is.<\/p>\n<p>The main application window allows you to change the icon &#8216;tip text&#8217; which is displayed when you hover on the icon in the system tray. You can also have the icon &#8216;blink&#8217; by pressing the &#8216;Blink&#8217; button. This can be used when some notification condition occurs within the main application.<br \/>\n<a href=\"http:\/\/anvil-of-time.com\/wordpress\/wp-content\/uploads\/2010\/12\/systraywindow.png\"><img loading=\"lazy\" class=\"aligncenter wp-image-622 size-full\" title=\"systraywindow\" src=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systraywindow.png\" alt=\"\" width=\"412\" height=\"292\" srcset=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systraywindow.png 412w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systraywindow-300x212.png 300w, https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systraywindow-150x106.png 150w\" sizes=\"(max-width: 412px) 100vw, 412px\" \/><\/a><br \/>\nThere is also a Bubblehelp button which is disabled. This should allow you to change the icon bubble help (and display the bubble help itself) but I am unable to get this to work. If anyone can figure it out I would appreciate knowing how.<\/p>\n<p>Many system tray applications pop up a menu allowing you to perform some standard list of options. I&#8217;ve provided some objects for this but have not implemented them in this application since I want the application to be more flexible in regards to notifications and processing options (hence the options window).<\/p>\n<p>You can <a href=\"https:\/\/anvil-of-time.com\/wp-content\/uploads\/2010\/12\/systray.zip\">download<\/a> a .Zip file which contains the .pbl and target as well as the exports for the objects. It was written in PB11.5.1<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One challenge for Powerbuilder developers today is the lack of current information\/programming tips relating to more current (10 and above) versions. This also applies to Windows versions as well. There are a variety of different solutions to having an application icon in the System Tray but almost without exception they relate to Windows 95\/98 primarily.&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[12,16,42],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/618"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=618"}],"version-history":[{"count":11,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/618\/revisions"}],"predecessor-version":[{"id":1898,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/618\/revisions\/1898"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}