Recent

Author Topic: [TTrayIcon] How to start application in SysTray  (Read 3836 times)

SniperX

  • New Member
  • *
  • Posts: 13
[TTrayIcon] How to start application in SysTray
« on: July 28, 2016, 07:57:55 pm »
Basically i want my application to start in the System Tray and when the user double clicks on TTrayIcon it shows up the Main Form and again double clicking on it should minimize it back to the system tray. If possible provide solutions where i won't need to call nasty WinApis xD

Also, i have already added Application.ShowMainForm:=False; to my projects .lpr file

Handoko

  • Hero Member
  • *****
  • Posts: 5524
  • My goal: build my own game engine using Lazarus
Re: [TTrayIcon] How to start application in SysTray
« Reply #1 on: July 28, 2016, 08:26:11 pm »
Try this:
Code: Pascal  [Select][+][-]
  1. begin
  2.   if frmMain.Showing then
  3.     frmMain.Hide
  4.   else
  5.     frmMain.Show;
  6. end;

Put the code inside TTrayIcon.OnDblClick.

Note: I haven't test the code. It may or may not work correctly.

shobits1

  • Sr. Member
  • ****
  • Posts: 271
  • .
Re: [TTrayIcon] How to start application in SysTray
« Reply #2 on: July 28, 2016, 09:47:54 pm »
Try this:
Code: Pascal  [Select][+][-]
  1. begin
  2.   if frmMain.Showing then
  3.     frmMain.Hide
  4.   else
  5.     frmMain.Show;
  6. end;

Put the code inside TTrayIcon.OnDblClick.

Note: I haven't test the code. It may or may not work correctly.

Works under win10.

SniperX

  • New Member
  • *
  • Posts: 13
Re: [TTrayIcon] How to start application in SysTray
« Reply #3 on: July 29, 2016, 04:57:08 am »
Try this:
Code: Pascal  [Select][+][-]
  1. begin
  2.   if frmMain.Showing then
  3.     frmMain.Hide
  4.   else
  5.     frmMain.Show;
  6. end;

Put the code inside TTrayIcon.OnDblClick.

Note: I haven't test the code. It may or may not work correctly.

Thanks, i tested and it worked.

 

TinyPortal © 2005-2018