Solved

hide show app from task bar

Posted on 2004-10-04
3
286 Views
Last Modified: 2010-04-05
Hi.
 Use this code to hide my application from task bar :

  ShowWindow(Application.Handle, SW_HIDE);

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

  ShowWindow(Application.Handle, SW_SHOW);

but how can i restore task bar (to show my application on task bar).

This is second question:
I want when I minimize the application (from task bar) the main form stay normal (not minimized)
0
Comment
Question by:nikola_mk
3 Comments
 
LVL 17

Assisted Solution

by:mokule
mokule earned 50 total points
ID: 12220641
Hi,
I'm not sure whether I understand You

  ShowWindow(Application.Handle, SW_HIDE);

  SetWindowLong(Application.Handle, GWL_EXSTYLE,
          GetWindowLong(Application.Handle, GWL_EXSTYLE) and (not WS_EX_TOOLWINDOW));

  ShowWindow(Application.Handle, SW_SHOW);
0
 
LVL 12

Assisted Solution

by:Ivanov_G
Ivanov_G earned 25 total points
ID: 12220761
1) ShowWindow(Application.Handle, SW_SHOW);

2) use Application.OnMinimize event
0
 
LVL 6

Accepted Solution

by:
so3 earned 25 total points
ID: 12222036
On the first question to show/hide the application simply put the icon of the program to be shown near the clock in the taskbar and double click to show/hide the app.

On the second question you can use as Ivanov_G said the  Application.OnMinimize event or see the coment from my code to handle the minimize event.

Here is the code to do it.


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,ShellApi;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
      procedure WndProc(var Msg : TMessage); override;
    { Private declarations }
  public
    { Public declarations }
    IconNotifyData : TNotifyIconData;
    Procedure ShowHide;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WndProc(var Msg : TMessage);
var
   p : TPoint;
begin
  case Msg.Msg of
    WM_USER+1:
    case Msg.lParam of
      WM_RBUTTONUP: begin
        GetCursorPos(p);
      end;
      WM_LBUTTONUP: begin
         ShowHide;
      end;
    end;
  end;
  if (Msg.Msg = WM_SYSCOMMAND) and (Msg.wParam = SC_MINIMIZE) then begin
     ShowHide; //here you can do the stuff on your second question
    Msg.wParam := 0;
    Msg.lParam :=0;
  end;
  inherited;
end;

Procedure TForm1.ShowHide;
begin
  if form1.Showing then Form1.Hide
          else form1.Show;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
with IconNotifyData do begin
     hIcon :=Application.Icon.Handle;
     uCallbackMessage := WM_USER + 1;
     cbSize := sizeof(IconNotifyData);
     Wnd := Handle;
     uID := 100;
     uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
  end;
  StrPCopy(IconNotifyData.szTip, Form1.Caption);
  Shell_NotifyIcon(NIM_ADD, @IconNotifyData);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    Shell_NotifyIcon(NIM_DELETE, @IconNotifyData);
    Application.ProcessMessages;
end;

end.

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now