Solved

How do I make my app hide from the taskbar.

Posted on 2000-02-27
13
333 Views
Last Modified: 2010-04-04
How do I hide my application from the windows taskbar? I want my application to load in the system try witch i use a component called TrayIcon. But when I minimize my application, I want it to stay in the try and hide from the taskbar. I have tried:

ShowWindow(Application.Handle, SW_HIDE);

SetWindowLong(Application.Handle, GWL_EXSTYLE,
GetWindowLong(Application.Handle, GWL_EXSTYLE)
WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);

But all the above code does hide my application from the taskbar until I minimize it. Then a window appears on my desktop like a child Mdi window.

How can i fix this?

Thank's TCSCode.
0
Comment
Question by:TCSCode
[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
  • 4
  • 3
  • 2
  • +4
13 Comments
 
LVL 1

Expert Comment

by:cobramania
ID: 2562558
Try these two codes:

procedure TServerForm.FormCreate(Sender: TObject);
begin
  ServerForm.Top := 5000;
end;


procedure TServerForm.FormActivate(Sender: TObject);
begin
  Application.Minimize;
  ShowWindow(Application.Handle, SW_HIDE);
end;


The first code is for creating the first form on top = 5000, so it's off the user screen, so the user can't see the blinking for while it disappear

The second code is for minimize it and then hide it.

Hope this helps :)
0
 
LVL 17

Expert Comment

by:inthe
ID: 2563265
listening..
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2563991
Add this line to the first line of your project (*.dpr):

[begin]

  SetWindowLong(Application.Handle, GWL_EXSTYLE, GetWindowLong(Application.Handle, GWL_EXSTYLE) or WS_EX_TOOLWINDOW);

[Application.Initialize;
 ...]

Regards, Madshi.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:TCSCode
ID: 2564683
When I load my Application I want to use it. When I minimize my application I want it to disapear like Hideing the form ( Form1.Hide )  But with all the code i have shown you and all the code that I have been given in this question does'nt work completely. When I minimize my application useing Application.Minimize; I see a toolwindow or whatever it's called above my taskbar and on the desktop. How can I fix that problem I am useing Delphi 5 Pro. Thank's.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2564771
Try this:

type
  TYourMainForm = class(TForm)
  private
    procedure SysCommand(var Message: TWMSYSCOMMAND); message WM_SYSCOMMAND;
    ...

procedure TYourMainForm.SysCommand(var Message: TWMSYSCOMMAND);
begin
  if Message.CmdType and $FFF0 = SC_MINIMIZE then begin
    Message.result := 0;
    Hide;
  end else
    inherited;
end;

This should fix the behaviour when the user clicks the minimize button. Don't call Application.Minimize, call Application.MainForm.Hide instead.
0
 

Expert Comment

by:WMPeters
ID: 2565168
I had the same problem. The solution was placing the code in the right event of the form. Try different events, like create, or onactivate. I can look it up for you when i'm at home, but with a little puzzling you will find it. (sorry that i can not tell you the right event now, i'm at work...;) )

By the way, you used the right code. I can also give you the code to let it dissappear from the events list (when you press CTRL-ALT-DEL, again, i shall look it up for you.)
0
 
LVL 1

Expert Comment

by:titz
ID: 2573753
hi,

you must hide the parent-window , which is created by delphi and not shown! that is the solution.
you must only make a small change in your code:

var
owner:thandle;

begin
....
owner:=getwindow(handle,GW_OWNER);
showwindow(owner,SW_HIDE);
....
end;

These two lines of code you must insert, when the window shall be hidden from  the taskbar.

cheers
titz
0
 
LVL 1

Expert Comment

by:titz
ID: 2573762
sorry, one line code forgotten:

correct is:
.....
owner:=getwindow(handle,GW-OWNER);
showwindow(owner,SW_HIDE);
self.hide;
.....

this is now correct.

titz

0
 

Author Comment

by:TCSCode
ID: 2579131
Still does'nt work.
0
 

Author Comment

by:TCSCode
ID: 2579134
titz your code is what i am looking for thank's to get your points just answer this message and i'll send them. Thank's.
0
 

Accepted Solution

by:
Iliad earned 200 total points
ID: 2591663
Try doing the following in your project file...


To do this you will need to:
 
   Select the View - Project Source, from Delphi's main menu.
   Add the Windows unit to the uses clause.
   Add Application.ShowMainForm := False; to the line after "Application.Initialize;".
   Add: ShowWindow(Application.Handle, SW_HIDE); to the line before "Application.Run;" Your main project source file should now look something like
   this: program Project1; uses Windows, Forms, Unit1 in 'Unit1.pas' {Form1}, Unit2 in 'Unit2.pas' {Form2}; {$R *.RES} begin Application.Initialize;
   Application.ShowMainForm := False; Application.CreateForm(TForm1, Form1); Application.CreateForm(TForm2, Form2);
   ShowWindow(Application.Handle, SW_HIDE); Application.Run; end.
   In the "initialization" section (at the very bottom) of each unit that uses a form, add: begin ShowWindow(Application.Handle, SW_HIDE); end.
0
 
LVL 1

Expert Comment

by:titz
ID: 2592953
hi TCSCode,
you can choose my comment as answer. then i will get the points.
Therefor it is not necessary that i send a new answer !

sorry for i am retutning so late, but here was canaval ! you know, ...

cheers
titz
0
 

Author Comment

by:TCSCode
ID: 2594388
No problem, Thank's again.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month8 days, 17 hours left to enroll

615 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