Delphi主視窗工作列菜單的問題(轉寄WM_SYSCOMMAND到Application)

來源:互聯網
上載者:User

標籤:

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)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.