Solved

Showing a form without displaying it in taskbar

Posted on 1998-09-11
4
187 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 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

19 Experts available now in Live!

Get 1:1 Help Now