Solved

Preventing the main form in showing up

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
Delphi XE2 application frozen on Windows 10 10 337
Delphi TcxGrid group footer summary 3 314
Performance of SQL statement 37 127
Slow Restore if incremental backups using RDiff.exe 4 29
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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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