Solved

Preventing the main form in showing up

Posted on 2002-04-11
4
165 Views
Last Modified: 2010-04-04
Hi

I'm writing an application that is only going to show up in the Windows statusbar as an icon. I can control the icon in the statusbar, but I can't prevent the main form and the button in the taskbar from showing. I now have the following lines in the form's OnActivate, but the form and the button show up for a short period, and it is not looking good.

ShowWindow(Application.Handle, SW_HIDE);
ShowWindow(Handle, SW_HIDE);

Is there any way i can prevent the form and the button in showing at all?

Thanks...
Regards
0
Comment
Question by:ON031699
  • 2
4 Comments
 
LVL 5

Expert Comment

by:alanwhincup
ID: 6934680
Try this:

initialization
begin
  SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;

Cheers,

Alan
0
 
LVL 1

Author Comment

by:ON031699
ID: 6934718
Is it not the same as setting the property 'BorderStyle' to bsToolWindow.
well, eather way, it did not change anything, sadly.

Regards
0
 
LVL 10

Accepted Solution

by:
Jacco earned 50 total points
ID: 6934789
Hi there,

You might also add:

Application.ShowMainForm := False;

In the DPR before Application.Run.

The position of the following code might be important. I found it works best in the FormCreate (after the inherited).

ShowWindow(Application.Handle, SW_SHOW);
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
ShowWindow(Application.Handle, SW_HIDE);

Here is another snippet I found:

http://www.delphicorner.f9.co.uk/articles/apps3.htm

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1},
  Windows;

{$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.

Regards Jacco

P.S. I will look in my code at work tomorrow I know the first suggestion consists of three calls but I am not sure about the ShowWindow parts.
0
 
LVL 1

Author Comment

by:ON031699
ID: 6934922
Thanks for the help Jacco, it appears to be working perfectly. Only 1 line of code did the trick, the one with ShowMainForm := False, before Application.Run. I don't even have the ShowWindow lines anymore and neither the form nor the button are showing up, great!!!

Regards
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

12 Experts available now in Live!

Get 1:1 Help Now