Solved

Taskbar button problem

Posted on 1998-09-16
10
373 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mobile Keyboard covers the display of the TMemo 3 78
Delphi XE10 Round Image 2 76
Find and Replace Stream with 0s 8 56
Delphi...Split view - idea? 1 40
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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

919 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

14 Experts available now in Live!

Get 1:1 Help Now