Secondary form minimized from taskbar icon

Giganews Newsgroups
Subject:Secondary form minimized from taskbar icon
Posted by: Alexandre Valiquette
Date:Tue, 30 Dec 2008

Hello!

I'm trying to do the following in Delphi 2009:

1) When I minimize any form at runtime in my project, the whole application minimizes.
2) If I click on the application's taskbar icon, the application forms are minimized or restored with the correct animation (depending of the active form state).

Basically I want all the forms of my application to share the same taskbar icon.

So far I managed to do 1) this way:

procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;

procedure TMyForm.WMSysCommand;
begin
    case Msg.CmdType of
        SC_MINIMIZE: Application.Minimize;
        SC_RESTORE: Application.Restore;
        else
            DefaultHandler(Msg);
    end;
end;

This works OK (but not sure it's the best way) but when secondary forms are restored (by clicking the taskbar icon) I see no restoring animation. Also I can't minimize secondary forms by clicking the taskbar icon (the popup menu is not even present on the taskbar icon when a secondary form is active)...

I know I can play with CreateParams and WS_EX_APPWINDOW to add a new icon to the taskbar for each form, but I only want one taskbar icon for my whole application...

Any idea on how to do this? Hope I am clear enough...

Replies