Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get taskbar buttons for forms that aren't the main form?

How do you make a form appear on the taskbar in Delphi? In Firefox, for example, when you open a page in a new window, it creates another window on the taskbar without creating a new process. At the moment my Delphi application opens a new form when a button is clicked, but there is still only one thing on the task bar, so you can't alt-tab between the main form and the form that is created when the button is clicked. How do I change it so that the new form appears with a new taskbar button? My current code looks like this:

procedure Form1ButtonClick(Sender: TObject);
begin
    Form2.Show;
end;

I have been messing around with CreateWindowEx, but ideally I would like to find a simpler solution than directly using the Windows API.

like image 469
Nicholas Grasevski Avatar asked Mar 30 '11 23:03

Nicholas Grasevski


People also ask

How do I customize the taskbar buttons?

Change your taskbar settingsPress and hold or right-click any empty space on the taskbar, and then select Taskbar settings. In the Taskbar settings, scroll to see the options for customizing, choosing icons, and much more.

How do I customize apps on my taskbar?

To pin apps to the taskbarSelect Start , scroll to the app you want to pin, then press and hold (or right-click) the app. Select More > Pin to taskbar. If the app is already open on the desktop, press and hold (or right click) the app's taskbar icon, and then select Pin to taskbar.


2 Answers

If I understand what you want correctly, you can show your secondary forms on the task bar by overriding it's CreateParams procedure, as explained in Minimize child forms independent of the main form delphi.about.com article, like this:

interface

type
  TMyForm = class(TForm)
  ...
  protected
    procedure CreateParams(var Params: TCreateParams) ; override;
  ...

implementation

procedure TMyForm.CreateParams(var Params: TCreateParams) ;
begin
  inherited;
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
  Params.WndParent := 0;
end;
like image 194
jachguate Avatar answered Oct 19 '22 03:10

jachguate


if not using of this line is better in form order :

Params.WndParent := 0;
like image 1
MohsenB Avatar answered Oct 19 '22 01:10

MohsenB