Time enough has passed that I haven't answered here.
As I mentioned already, the reason you see a button on the taskbar is because the
application puts it there. Your forms don't. You can see this by going to the main menu --> Project --> Options --> Application --> Title and giving your application a title that differs from the main form's caption. The button on the taskbar will show the application title, and not the mainform caption.
When you have MDI children, which cannot be hidden, the application button is restored to the taskbar because you technically still have windows showing... even if the MDI main form is hidden.
So, to get rid of it you have to turn it off explicitly. In
MAIN.pas, make sure you have the following:
interface
type
TMainForm = class(TForm)
procedure ApplicationActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
private:
procedure SysCommandMessage(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
protected:
procedure CreateParams(var Params: TCreateParams); override;
end;
implementation
procedure TMainForm.ApplicationActivate( Sender: TObject );
begin
// Remove the application button from the taskbar
// (and make sure it stays that way)
ShowWindow( Application.Handle, SW_HIDE )
end;
procedure TMainForm.FormCreate( Sender: TObject );
begin
// Keep the application button out of the taskbar
application.OnActivate := ApplicationActivate
end;
procedure TMainForm.SysCommandMessage(var Msg: TWMSysCommand);
begin
// Routing WM_SYSCOMMAND messages through here instead of the default
// handler prevents Delphi from trying to create a taskbar button for the
// application when minimized and maximized, which when combined with
// ApplicationActivate would otherwise cause flicker.
//
// You could capture the SC_MINIMIZE command here and instead hide the
// window, but you would have to make sure to let the user know that the
// window was minimized to the system tray. Otherwise it will look like the
// window just disappeared...
//
// You could also remove biMinimize and biMaximize from the mainForm's
// BorderIcons, and trap the SC_MINIMIZE button to do nothing... For
// example:
// if msg.CmdType <> SC_MINIMIZE then defaultHandler( msg )
//
defaultHandler(Msg)
end;
procedure TMainForm.CreateParams(var Params: TCreateParams);
begin
// Add the main form's window button to the taskbar
inherited CreateParams(Params);
Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
Params.WndParent := GetDesktopWindow
// If I understand things correctly, if you comment out the last line then
// when you manipulate the window (say, restore it) other toplevel windows
// belonging to the application will also be affected (say, restored). But
// since this is an MDI application you shouldn't have any other toplevel
// windows... And I haven't played around with this any...
end;
If you insert this code into your main form you will get the taskbar button response you want. Weird stuff, huh?
I'll post back in a few days more with a fairly interesting example (I've been having fun with it, but my simple object pascal syntax highlighter needs a little more work...) which comes with all its own source code and demonstrates all kinds of weird things, such as how to make an application mutex to prevent multiple instances of the application from running at the same time, tray icon popup menus and animations, using XP style controls if available, etc.