* * *

Author Topic: Making TTrayIcon and TForm behave like Windows buttton  (Read 252 times)

Pascal

  • Sr. Member
  • ****
  • Posts: 477
Making TTrayIcon and TForm behave like Windows buttton
« on: August 11, 2017, 08:57:28 am »
I am going to implement a little tool with tray icon to display a window with UI.

The thing i want to achive is:
1. On click on tray icon toggle visibility of form
2. On click on other app or desktop (outside form) hide form

1 could be achived by toggling Visible property form.
2 could be achived by assigning method to Application.OnDeactivate

But on button down on tray icon the app is deactivated (which hides it).

Is there an other way to make the tray icon and the form behave like the windows startmenu?
laz trunk - fpc trunk 32bit - Windows 10 Pro x64

RAW

  • Sr. Member
  • ****
  • Posts: 411
Re: Making TTrayIcon and TForm behave like Windows buttton
« Reply #1 on: August 11, 2017, 12:32:49 pm »
What about something else:
Maybe a Timer: If Not PtInRect BoundsRect... then Hide or Hide with delay...

MouseMove wouldn't help much I guess...

Just a thought...
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.6.4 FPC 3.0.2

RAW

  • Sr. Member
  • ****
  • Posts: 411
Re: Making TTrayIcon and TForm behave like Windows buttton
« Reply #2 on: August 12, 2017, 05:17:57 pm »
I tried this... and BoundsRect isn't working (1.6.4 and 1.8RC3)...
ClientRect is working, but useless in this case... I guess nobody needs BoundsRect...  :D

EDIT: Ok, BoundsRect works, but there is a problem with the bottom part of the form...
In combination with bsNone it's working fine.
« Last Edit: August 12, 2017, 08:12:20 pm by RAW »
Windows 7 Pro (x64 Sp1) And Windows XP Pro (x86 Sp3) - LAZARUS 1.6.4 FPC 3.0.2

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus