Solved

Showing a form without displaying it in taskbar

Posted on 1998-09-11
4
185 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

7 Experts available now in Live!

Get 1:1 Help Now