Solved

Preventing the main form in showing up

Posted on 2002-04-11
4
166 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

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, DigitalPersona Fingerprint reader and MySQL 6 220
Print Graphic and Text to Epson TM-T88v 12 184
find a node in VST 2 64
Create a path if not exists 7 69
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

16 Experts available now in Live!

Get 1:1 Help Now