[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

Taskbar button problem

 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
zoltan082098
Asked:
zoltan082098
  • 4
  • 3
  • 2
  • +1
1 Solution
 
MadshiCommented:
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
 
viktornetCommented:
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
 
zoltan082098Author Commented:
 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
Industry Leaders: 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!

 
zoltan082098Author Commented:
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
 
viktornetCommented:
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
 
viktornetCommented:
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
 
zoltan082098Author Commented:
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
 
viktornetCommented:
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
 
adrenalindxCommented:
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
 
adrenalindxCommented:
oopssorry rong question lol
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now