Recent

Author Topic: TfpgSystemTrayIcon in Fpgui  (Read 6222 times)

benohb

  • Full Member
  • ***
  • Posts: 218
TfpgSystemTrayIcon in Fpgui
« on: February 02, 2019, 03:43:17 am »
Google does not help much
How use TfpgSystemTrayIcon in Fpgui
Any examples? I use Linux   %)
« Last Edit: February 02, 2019, 03:57:26 am by benohb »

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: TfpgSystemTrayIcon in Fpgui
« Reply #1 on: May 10, 2019, 05:13:17 pm »
Sorry for the late reply. I've already added an example to the documentation, but the current online docs is equivalent to the "master" branch (last stable released branch), and not the more up-to-date "maint" or "develop" branches.

Anyway, add the following code to your main form's AfterCreate() method.

Code: Pascal  [Select][+][-]
  1.   pmTray := TfpgPopupMenu.Create(self);
  2.   with pmTray do
  3.   begin
  4.     Name := 'pmTray';
  5.     SetPosition(256, 128, 120, 20);
  6.     AddMenuItem('Start Timer...', '', nil);
  7.     AddMenuItem('Stop Timer...', '', nil);
  8.     AddMenuItem('-', '', nil);
  9.     AddMenuItem('Show Form', '', @miShowFormClicked);
  10.     AddMenuItem('-', '', nil);
  11.     AddMenuItem('Quit', '', @miFileQuitClicked);
  12.   end;
  13.  
  14.   TrayIcon := TfpgSystemTrayIcon.Create(self);
  15.   with TrayIcon do
  16.   begin
  17.     Name := 'TrayIcon';
  18.     SetPosition(256, 240, 20, 20);
  19.     PopupMenu := pmTray;
  20.     ImageName := 'stdimg.folderhome';
  21.   end;
  22.  

You define a popup menu, which in turn you will assign to the PopupMenu property of the systemtray component. There are a couple of properties you can adjust to configure the systemtray appearance.

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

 

TinyPortal © 2005-2018