Re: Standard system menu for Main form
- From: Duncan McNiven <spamtrap@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 23 Oct 2005 13:06:29 +0300
On Sun, 23 Oct 2005 02:04:22 GMT, Ian <ian610@xxxxxxxxxxxxxxxx> wrote:
>As many of you probably already know, if you right click a
>Delphi written application's taskbar icon, the standard system
>menu items are missing (i.e. Maximize, Move, Size).
This is because those menu items are part of the form's system menu
but the task bar icon is owned by the application, not the form.
>Does anyone know of a simple method or even another component
>that will show the missing system menu items?
One approach is to disable the application's taskbar icon and add one
for the main form instead.
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
Procedure WMSyscommand(Var msg: TWmSysCommand);
message WM_SYSCOMMAND;
protected
Procedure CreateParams( Var params: TCreateParams ); override;
public
{ Public declarations }
end;
.....
procedure TForm1.FormCreate(Sender: TObject);
begin
ShowWindow( Application.handle, SW_HIDE );
SetWindowLong( Application.handle,
GWL_EXSTYLE,
GetWindowLong( application.handle, GWL_EXSTYLE ) and
not WS_EX_APPWINDOW or WS_EX_TOOLWINDOW);
ShowWindow( Application.handle, SW_SHOW );
end;
procedure TForm1.WMSyscommand(var msg: TWmSysCommand);
begin
case (msg.cmdtype and $FFF0) of
SC_MINIMIZE: begin
ShowWindow( handle, SW_MINIMIZE );
msg.result := 0;
end;
SC_RESTORE: begin
ShowWindow( handle, SW_RESTORE );
msg.result := 0;
end;
else
inherited;
end;
end;
procedure TForm1.CreateParams(var params: TCreateParams);
begin
inherited CreateParams( params );
params.ExStyle := params.ExStyle or WS_EX_APPWINDOW;
end;
.
- References:
- Standard system menu for Main form
- From: Ian
- Standard system menu for Main form
- Prev by Date: Re: Program closure
- Next by Date: specifying cached updates properties at runtime
- Previous by thread: Standard system menu for Main form
- Next by thread: specifying cached updates properties at runtime
- Index(es):