Solved

Preventing the main form in showing up

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to convert wav to mp3 in delphi 9 196
proper way to parse url in delphi 2 192
Print Graphic and Text to Epson TM-T88v 12 241
Twebbrowser add css to the header 3 24
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

813 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

11 Experts available now in Live!

Get 1:1 Help Now