d6mdimsgfix.pas

来自「Jedi Code Library JCL JVCL 组件包 JCL+JVCL超」· PAS 代码 · 共 61 行

PAS
61
字号
unit D6MdiMsgFix;

interface

{$I jcl.inc}

implementation

{$IFDEF DELPHI6}

uses
  Windows, Classes, SysUtils, Forms, AppEvnts;

type
  TFixApplicationEvents = class(TCustomApplicationEvents)
  protected
    procedure ApplicationEventsMessage(var Msg: TMsg; var Handled: Boolean);
  public
    constructor Create(AOwner: TComponent); override;
  end;

  TApplicationAccess = class(TApplication);

var
  FixApplicationEvents: TFixApplicationEvents;

{ TFixApplicationEvents }

procedure TFixApplicationEvents.ApplicationEventsMessage(var Msg: TMsg; var Handled: Boolean);
begin
  with Application do
    if Assigned(MainForm) and (MainForm.FormStyle = fsMDIForm) and
      Assigned(Screen.ActiveForm) and (Screen.ActiveForm.FormStyle <> fsMdiChild) then
      begin
        Handled := True;
        with TApplicationAccess(Application) do
          if not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
          begin
            // prevent to call buggy TApplication.IsMDIMsg method, handle message here
            TranslateMessage(Msg);
            DispatchMessage(Msg);
          end;
      end;
end;

constructor TFixApplicationEvents.Create(AOwner: TComponent);
begin
  inherited;
  OnMessage := ApplicationEventsMessage;
end;

initialization
  FixApplicationEvents := TFixApplicationEvents.Create(nil);

finalization
  FreeAndNil(FixApplicationEvents);

{$ENDIF DELPHI6}

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?