Hi,
I also need it for a project, and tried to get it to work a couple of months ago. I had go leave the project for a while though, so I don't have it with me and forgot precisely all the issues.
I do remember though that it seemed like a problem with how the LCL passes on windows messages (?). In the main callback routine for windows all the messages are filtered, and 'unknown' messages are ignored, or something like that - help me out :-)
Anyways, the best I could do in the end was to write a separate unit that maintains its own window with a trayicon, though I haven't finished this.
If I am wrong about anything, feel free to correct me.
Regards,
C
SteveG <[EMAIL PROTECTED]> wrote:
SteveG <[EMAIL PROTECTED]> wrote:
Thanks guys - I understand this would only be useful on Windows, but
still would like it to work :)
The code below works fine in delphi - cant seem to get it to work with
Lazarus though.
I have commented the changes I have had to make to get it to compile /
run in Laz.
Any ideas ?
unit Unit1;
{$mode objfpc}{$H+}
interface
uses Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
ExtCtrls, Windows, ShellApi;
const WM_ICONTRAY = WM_USER +1;
type
{ TForm1 }
TForm1 = class(TForm)
Image1: TImage;
procedure Form1Create(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
procedure TrayMessage( var Msg: TMessage ); message WM_ICONTRAY;
end;
var
Form1: TForm1;
TrayIconData :TNotifyIconData;
implementation
procedure TForm1.Form1Create(Sender: TObject);
begin
with TrayIconData do begin
cbSize := SizeOf(TrayIconData);
hWnd :=
Handle;
// delphi - Wnd := Handle;
uID := 0;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
uCallbackMessage := WM_ICONTRAY;
hIcon :=
0;
// delphi - hIcon := Application.Icon.Handle;
StrPCopy(szTip, Application.Title);
end;
Shell_NotifyIcon(NIM_Add,
PNOTIFYICONDATAA(@TrayIconData)); // delphi -
Shell_NotifyIcon(NIM_Add, @TrayIconData);
end;
procedure TForm1.TrayMessage( var Msg: TMessage );
begin
case Msg.lParam of
WM_LBUTTONDOWN: ShowMessage('Left button');
WM_RBUTTONDOWN: ShowMessage('Right button');
end;
end;
Initialization
{$I unit1.lrs}
Finalization
Shell_NotifyIcon(NIM_DELETE, PNOTIFYICONDATAA(@TrayIconData));
end.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
