码迷,mamicode.com
首页 > 移动开发 > 详细

Delphi主窗口任务栏菜单的问题(转发WM_SYSCOMMAND到Application)

时间:2016-03-18 00:17:30      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:

Delphi的VCL框架在创建应用时TApplication是一个自动创建的隐藏窗口,其它创建的窗口是自动以该窗口为窗口,这就导致创始的主窗口在任务栏的系统菜单只有三项,只要在主窗口的Create事件中将系统菜单用Application的系统菜单替换,并将SysCommand消息转发到主窗口就正常了。

 

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    procedure OnMessage(var Msg: TMsg; var Handled: Boolean);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  GetSystemMenu(Application.Handle,True);
  Application.OnMessage:=OnMessage;
end;

procedure TForm1.OnMessage(var Msg: TMsg; var Handled: Boolean);
begin
  case Msg.message of
    WM_SYSCOMMAND:
      begin
        SendMessage(Handle,Msg.message,Msg.wParam,Msg.lParam);
        Handled:=True;
      end;
  end;
end;

end.

http://blog.csdn.net/missmecn/article/details/5319592

Delphi主窗口任务栏菜单的问题(转发WM_SYSCOMMAND到Application)

标签:

原文地址:http://www.cnblogs.com/findumars/p/5290050.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!