Solved

hide show app from task bar

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: how to implement a User Shortcut mapper? 1 107
oracle global variables 4 68
CheckListBox usage 3 58
Delphi and Access based Enumeration 9 59
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

815 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

11 Experts available now in Live!

Get 1:1 Help Now