相关疑难解决方法(0)

从NC区域删除vcl样式时,不显示TMainMenu

我正在使用此代码从表单的非客户区域中删除vcl样式.

type
  TFormStyleHookNC= class(TMouseTrackControlStyleHook)
  protected
    procedure PaintBackground(Canvas: TCanvas); override;
    constructor Create(AControl: TWinControl); override;
  end;

constructor TFormStyleHookNC.Create(AControl: TWinControl);
begin
  inherited;
  OverrideEraseBkgnd := True;
end;

procedure TFormStyleHookNC.PaintBackground(Canvas: TCanvas);
var
  Details: TThemedElementDetails;
  R: TRect;
begin
  if StyleServices.Available then
  begin
    Details.Element := teWindow;
    Details.Part := 0;
    R := Rect(0, 0, Control.ClientWidth, Control.ClientHeight);
    StyleServices.DrawElement(Canvas.Handle, Details, R);
  end;
end;


initialization
 TStyleManager.Engine.RegisterStyleHook(TForm3, TFormStyleHookNC);
Run Code Online (Sandbox Code Playgroud)

在应用此样式挂钩之前,表单看起来像

在此输入图像描述

之后

在此输入图像描述

正如您所看到的菜单消失,问题是:我如何解决这个问题?我是说如何在不删除TMainMenu的情况下从表单的非客户区删除vcl样式?

delphi delphi-xe2 vcl-styles

4
推荐指数
1
解决办法
1200
查看次数

标签 统计

delphi ×1

delphi-xe2 ×1

vcl-styles ×1