Recent

Author Topic: TrayIcon - tray size  (Read 9152 times)

Dibo

  • Hero Member
  • *****
  • Posts: 1057
TrayIcon - tray size
« on: February 15, 2011, 11:44:59 pm »
Hi,

I'm looking at TTrayIcon methods but don't see any function which get me some kind of tray TRect. I want know tray size. On windows it is 16x16 (if I remember correctly), gnome have 24x24 (default) and QT (KDE) have much bigger than gnome. On Gnome I can change this size in settings so I can't use OS constants. I just want know current tray size to peek correct set of images on runtime.

Regards

fafastrungen

  • New Member
  • *
  • Posts: 24
Re: TrayIcon - tray size
« Reply #1 on: February 28, 2011, 08:54:47 pm »
Use Canvas property, for example:

trayIcon.Canvas.Width;
trayIcon.Canvas.Height;

zeljko

  • Hero Member
  • *****
  • Posts: 1797
    • http://wiki.lazarus.freepascal.org/User:Zeljan

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: TrayIcon - tray size
« Reply #3 on: March 02, 2011, 12:23:11 am »
Hi how do you resize the tray icon?
Trayicon1.Icon.SetSize(TrayIcon1.Canvas.Width,TrayIcon1.Canvas.Height);         
Results in run error: invalid graphic operation.

Also, how does one define which button click for popupmenu eg Linux by default is mouseL windows is mouseR. Software is for multiplatform.
I would leave trayicon popupmenu event blank and use trayicon.onclick event and define from there, but any better suggestion appreciated.

Thanks vm
Alistair.
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

rajivsoft

  • New Member
  • *
  • Posts: 48
Re: TrayIcon - tray size
« Reply #4 on: March 02, 2011, 02:23:05 pm »
Hi how do you resize the tray icon?
Trayicon1.Icon.SetSize(TrayIcon1.Canvas.Width,TrayIcon1.Canvas.Height);         
Results in run error: invalid graphic operation.

Also, how does one define which button click for popupmenu eg Linux by default is mouseL windows is mouseR. Software is for multiplatform.
I would leave trayicon popupmenu event blank and use trayicon.onclick event and define from there, but any better suggestion appreciated.

Thanks vm
Alistair.
I think you need to load different icons for different platforms, make a define conditioned load on create of main form for example.
Same thing for onclick event, better use onmousedown and conditional control button = mbleft (for ifdef darwin) or button = mbright (for ifdef win32)

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: TrayIcon - tray size
« Reply #5 on: March 03, 2011, 07:28:31 am »
I think you need to load different icons for different platforms, make a define conditioned load on create of main form for example.
Same thing for onclick event, better use onmousedown and conditional control button = mbleft (for ifdef darwin) or button = mbright (for ifdef win32)
Hi for some reason I was not notified of your reply but thanks anyway here is what I have done which seems consistent with Thunderbird and Firefox in all platforms:
Code: [Select]
procedure TSettings.TrayIcon1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if Button=mbright then popupmenu1.PopUp() else Settings.Visible:=not Settings.Visible;
end;

As for the tray icon size there seems to be a problem with scaling if the resource file is anything but an .ico (icon) file. Then the size cannot be adjusted eg if its a png
« Last Edit: March 03, 2011, 07:31:20 am by Algeorge »
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

Dibo

  • Hero Member
  • *****
  • Posts: 1057
Re: TrayIcon - tray size
« Reply #6 on: March 04, 2011, 07:00:16 pm »
Sorry for delay
Use Canvas property, for example:

trayIcon.Canvas.Width;
trayIcon.Canvas.Height;
This give me 0 for width and height (tested on windows)
http://doc.trolltech.com/4.6/qsystemtrayicon.html#geometry
This is only for QT

 

TinyPortal © 2005-2018