Solved

Showing a form without displaying it in taskbar

Posted on 1998-09-11
4
189 Views
Last Modified: 2010-05-18
How could I show a form without displaying it in taskbar?
This form is the MainForm of my program, so setting border style to bsDialog doesn't help.
0
Comment
Question by:bvrab
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
duke_n earned 100 total points
ID: 1339380
There was exactly this question before(answered by Ronit). here is the answer.
to hide it from taskbar call the HideTaskClick procedure.to show again call the ShowTaskClick procedure:


procedure TForm1.HideTaskClick(Sender: TObject);
var wndHandle : THandle;
     wndClass : array[0..50] of Char;
begin
     StrPCopy(@wndClass[0], 'Shell_TrayWnd');
     wndHandle := FindWindow(@wndClass[0], nil);
     ShowWindow(wndHandle, SW_HIDE); // This hides the taskbar
end;

procedure TForm1.ShowTaskClick(Sender: TObject);
var wndHandle : THandle;
     wndClass : array[0..50] of Char;
begin
     StrPCopy(@wndClass[0], 'Shell_TrayWnd');
     wndHandle := FindWindow(@wndClass[0], nil);
     ShowWindow(wndHandle, SW_RESTORE); // This restores the taskbar
end;


0
 
LVL 1

Expert Comment

by:duke_n
ID: 1339381
No,man, sorry, this was to hide the taskbar!!!!! here how to hide FROM taskbar(put that in your PROJECT SOURCE):
program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Windows; //THIS IS REQUIRED TO SET THE WINDOW STYLE!

{$R *.RES}

//Declare a var to retrieve current window information
var
  ExtendedStyle : Integer;

begin
  Application.Initialize;

  //Get the Extended Styles of the Application, by passing its
  //handle to GetWindowLong
  ExtendedStyle := GetWindowLong(Application.Handle,
GWL_EXSTYLE);
  //Now, set the Extended Style by doing a bit masking operation.
  //OR in the WS_EX_TOOLWINDOW bit, and AND out the      
  //WS_EXAPPWINDOW bit  
  //This effectively converts the application from an App
  //Windows to a Tool Window.
  SetWindowLong(Application.Handle, GWL_EXSTYLE, ExtendedStyle OR WS_EX_TOOLWINDOW AND NOT WS_EX_APPWINDOW);
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.


0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339382
Here is something that I hope won't confuse you that much....

In your form's OnCreate() add this code....

SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);

Regards,
Viktor Ivanov
0
 

Author Comment

by:bvrab
ID: 1339383
Thank you for your answer (comment). I actually needed the code for C++ Builder and with slight changes this code works there as well.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

839 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