[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Preventing the main form in showing up

Posted on 2002-04-11
4
Medium Priority
?
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 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