How can I get a child form to appear on the windows taskbar in Delphi?
I have seen several applications where when a new window is opened, a new button for that child window is created on the taskbar, without creating a new process. By default, in an application written in Delphi, child forms can be created and displayed, but only one button appears on the Windows taskbar, they are not displayed separately when doing alttab.
how can i change this behaviour?
My current code looks like this:
procedure Form1ButtonClick(Sender: TObject);
begin
Form2.Show;
end;
I've been thinking about calling CreateWindowEx
, but my ideal solution should be simpler than having to call the Windows API directly.
You can achieve what you want by overriding the method
CreateParams
of the form(s) you want to have their own button on the taskbar. With the proposed solution, these forms will also be minified independently, like so:In fact, you can find a more extensive explanation (in English) in the article Minimize child forms independent of the main form at delphi.about.com
Note that the referenced article on about.com is incorrect about setting the form's WndParent to desktop. On the blog "The Old New Thing" we found a great explanation why it is wrong to make the desktop the parent of your application windows .
With information from How can I get taskbar buttons for forms that aren't the main form?