4

このコードを使用して、フォームの非クライアント領域から 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);

このスタイルフックを適用する前に、フォームは次のようになります

ここに画像の説明を入力

以降

ここに画像の説明を入力

ご覧のとおり、メニューが消えます。問題は、これをどのように修正できるかということです。TMainMenu を削除せずに、フォームの非クライアント領域から vcl スタイルを削除する方法を教えてください。

4

1 に答える 1

7

When you uses the vcl styles, the TMain menu is drawn by the TMainMenuBarStyleHook vcl style hook, which is defined inside of the TFormStyleHook (the hook of the forms), in this case because you are not using this hook there is not code to draw the TMainMenu.

Two possible solutions are

1) Implement the vcl style hook for the TMainMenu inside of the TFormStyleHookNC , just like the TFormStyleHook does.

2)or even better use a TActionMainMenuBar component instead of a TMainMenu, this component is very well integrated with the vcl styles (check the next sample image).

enter image description here

于 2012-08-15T03:00:59.143 に答える