Solved

hide show app from task bar

Posted on 2004-10-04
3
294 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month6 days, 20 hours left to enroll

623 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