Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Delphi]Create an Icon in System Tray[/Delphi]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
jongwee
Moderator
Reputation: 0

Joined: 28 Jun 2006
Posts: 1388
Location: Singapore

PostPosted: Sun Oct 28, 2007 9:24 pm    Post subject: [Delphi]Create an Icon in System Tray[/Delphi] Reply with quote

Code:

....

Const
  WM_ICONTRAY = WM_USER + 1;

Private
  procedure Icontray(var Msg: TMessage); message WM_ICONTRAY;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with NotifyIconData do begin
    hIcon := Icon.Handle;
    StrPCopy(szTip, Application.Title);
    Wnd := Handle;
    uCallbackMessage := WM_ICONTRAY;
    uID := 1;
    uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
    cbSize := sizeof(TNotifyIconData);
  end;
  Shell_NotifyIcon(NIM_ADD, @NotifyIconData);
    ShowWindow(Application.Handle, SW_HIDE);

  SetWindowLong(Application.Handle, GWL_EXSTYLE,
          GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);

  ShowWindow(Application.Handle, SW_SHOW);
end;

procedure TForm1.Icontray(var Msg: TMessage);
var
  CursorPos : TPoint;
begin
  if Msg.lParam = WM_RBUTTONDOWN then begin
    GetCursorPos(CursorPos);
    SetForegroundWindow(Handle);        // suggested by Berend Radstaat
    PopupMenu1.Popup(CursorPos.x, CursorPos.y);
    PostMessage(Handle, WM_NULL, 0, 0); // suggested by Berend Radstaat
  end else
    inherited;
end;


2) Go to your Project Manager, right click on your whatever.exe and select "View Source"
Code:

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm2, Form2);
  Application.CreateForm(TForm3, Form3);
  Application.Run;
end.


I'm not sure if the second step is necessary but just add it in case. If there is any thing I havent added, please tell me. Thanks! Very Happy

_________________
Back to top
View user's profile Send private message MSN Messenger
DoomsDay
Grandmaster Cheater
Reputation: 0

Joined: 06 Jan 2007
Posts: 768
Location: %HomePath%

PostPosted: Mon Oct 29, 2007 1:03 am    Post subject: Reply with quote

Um, you could use Additional>>TTrayIcon - just equip it with a popup and toggle it to visible... Hopes it makes it easier...
Back to top
View user's profile Send private message
compactwater
I post too much
Reputation: 8

Joined: 02 Aug 2006
Posts: 3923

PostPosted: Mon Oct 29, 2007 1:45 am    Post subject: Reply with quote

Don't forget to kill it on terminate. Razz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites