Solved

Taskbar button problem

Posted on 1998-09-16
10
371 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

20 Experts available now in Live!

Get 1:1 Help Now