Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

hide show app from task bar

Posted on 2004-10-04
3
Medium Priority
?
297 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 150 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 75 total points
ID: 12220761
1) ShowWindow(Application.Handle, SW_SHOW);

2) use Application.OnMinimize event
0
 
LVL 6

Accepted Solution

by:
so3 earned 75 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

886 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