Solved

Taskbar button problem

Posted on 1998-09-16
10
380 Views
Last Modified: 2010-04-06
 I want to make an application which has no button on taskbar (but has an icon in the Taskbar Notification Area). In the project file I made the application invisible (Application.ShowMainForm:=false), so at start I don’t have button on the taskbar. But when I show a form, the application’s button appears on the taskbar.
  I tried two things:
  1. Hiding the button with ShowWindow(Application.Handle, sw_Hide) in OnShow event handler --> the button appears for a moment.
  2. Using the ShowWindow(Form.Handle, sw_Restore) function instead of Form.Show method --> no button appears on the taskbar, but no components appear on the form. Showing each component on form is hard and -- especially -- very ugly.
0
Comment
Question by:zoltan082098
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1339917
zoltan,

you'll have to write a service application. Load Delphi help. Go to index. Look under service. Sorry, have no sources...

Regards, Madshi.
0
 
LVL 10

Accepted Solution

by:
viktornet earned 50 total points
ID: 1339918
Here is something you can do...

procedure TForm1.FormCreate(Sender: TObject);
begin
      SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
   SetWindowLong(Application.Handle, GWL_EXSTYLE, not WS_EX_TOOLWINDOW);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  Show;
  Timer1.Enabled := false;
end;

The timer's interval is set to 10000//10 secs
0
 

Author Comment

by:zoltan082098
ID: 1339919
 Viktornet,

  I don’t really understand what your code should do, but for sure not what I need. Fortunately the key idea -- using the WS_EX_ToolWindow style -- works, so I consider your answer acceptable.
  The solution is the following: in the project file I set the application’s window style as a tool window:

program ...

uses ..., Windows, ...

begin
  ...
  SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
  Application.Run;
end;

  Using this solution, I don’t have to do nothing in the forms’ OnShow handler, and by no means need a timer -- no button will appear on the task bar even just for a moment.

Regards,
Zoltan
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:zoltan082098
ID: 1339920
To Madshi: thanks for the tip, but there were nothing about my problem -- I think becouse you have Delphi 4 and I have Delphi 3.

Regards,
Zoltan
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339921
I know what you mean, and the code I gave you has nothing to do with what you want....I just wanted to show you the idea and an example on how to hide the taskbar button from the taskbar, and then show it back..That was the idea...
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339922
I'm just wondering why did you give me a D grade. If you didn't like it better don't accept my answer than giving me a D... I'm not for the 50 points....but I need to have somewhat good grades,,,,
//Vik
0
 

Author Comment

by:zoltan082098
ID: 1339923
Because when I read your answer, and I saw the timer and the OnShow event handler, I didn’t even want to try it. But I tried it and I saw what I expected -- your code doesn’t work. I wrote an answer why I reject it, but before pushing the submit button, I tried the WS_EX_ToolWindow style for the application window, in the project file.
I didn’t know that the grade is more important for you than the 50 points. I think that even a B answer must work without modifications (because it’s a GOOD answer), and a C answer must be close to the problem. When the answer doesn’t have even a single good line, and I have to think about how can I use this answer -- this is, for me, barely acceptable.
But no problem, if you want, I will give you A for each answer which seems to be acceptable.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339924
As I mentioned b4 this was just an example.... I needed to refresh the app so I needed to use the timer for that.....
-------
This procedure below hides the taskbar button of your app...
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
This next procedure makes it so the app button has to show up but for that to work I needed to update the form and I didn't wanted to take so much time to write the example... That's why I used the timer....and then disable it...

About the points I expect to have good grades, which is more important to me!

Regards,
Viktor Ivanov

SetWindowLong(Application.Handle, GWL_EXSTYLE,  not WS_EX_TOOLWINDOW);
0
 

Expert Comment

by:adrenalindx
ID: 8736541
procedure TForm1.Button2Click(Sender: TObject);
begin
ShowWindow( Application.Handle, SW_HIDE );
SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);

 //ShowWindow( Application.Handle, SW_SHOW );
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
ShowWindow( Application.Handle, SW_SHOW );
SetWindowLong(Application.Handle, GWL_EXSTYLE,  not WS_EX_TOOLWINDOW);

end;


iv got this 2 work but i cant get it to work by jus hidin one window, i hav to hide the whole app, even tried using handle insted of application.handle;
0
 

Expert Comment

by:adrenalindx
ID: 8736578
oopssorry rong question lol
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 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