Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

hide show app from task bar

Posted on 2004-10-04
3
Medium Priority
?
295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

718 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