Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   MainMenu ownerdrawn vs. Styles (https://www.delphipraxis.net/205526-mainmenu-ownerdrawn-vs-styles.html)

striderx 20. Sep 2020 09:54

MainMenu ownerdrawn vs. Styles
 
Ich habe für ein MainMenu mit Ownerdraw / MeasureItem / AdvancedDrawItem die Darstellung angepaßt (vor allem größere Schrift). Das klappt auch wunderbar, bis ich für die Anwendung (VCL) einen Style aktiviere. Dann werden die MenuItems der ersten Ebene nicht mehr korrekt dargestellt (auf den Ebenen darunter ist alles in Ordnung).

Jetzt kann man für ein MainMenu die Styles ja nicht selektiv deaktivieren (zumindest nicht über den Objekt-Inspektor). Hat jemand einen Tipp?

KodeZwerg 21. Sep 2020 08:07

AW: MainMenu ownerdrawn vs. Styles
 
Versuche mal auf TActionMainMenuBar umzustellen.
Damit sollten Styles funktionieren.

striderx 21. Sep 2020 09:32

AW: MainMenu ownerdrawn vs. Styles
 
Zitat:

Zitat von KodeZwerg (Beitrag 1473931)
Versuche mal auf TActionMainMenuBar umzustellen.

Auf TActionMainMenuBar bin ich auch schon gestossen, aber ich blicke da überhaupt nicht durch. Abgesehen davon würde das bedeuten, in mehreren Anwendungen ca. 80 MenuItems umzubauen - so reizvoll ist das dann auch nicht unbedingt.


Zitat:

Damit sollten Styles funktionieren.
Sollten? So genau weißt du das also auch nicht? :)


Ansonsten habe ich das hier gefunden:

Delphi-Quellcode:
TStyleManager.SystemHooks := TStyleManager.SystemHooks - [shMenus];


Ich bekomme es nur leider nicht zum funktionieren.

KodeZwerg 21. Sep 2020 09:47

AW: MainMenu ownerdrawn vs. Styles
 
Ich kann nicht für Deine Delphi Version sprechen. Bei 10.3 bin ich so an styled menus gekommen.
Es ist aufwändiger aber man mag was hinten raus kommt, sprich: es lohnt sich!

how-to-add-submenus-to-tactionmainmenubar-programatically auf stackoverflow zeigt einem wie man dynamisch vorgehen könnte.

Delphi-Quellcode:
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  iActionClientItem : TActionClientItem;
  iSubMenuItem : TActionClientItem;
  iFileAction : TCustomAction;
  iChildMenu : TActionBarItem;
begin
  ActionManager1.AddSeparator( ActionManager1.FindItemByAction(FileExit1), FALSE );
  iActionClientItem := ActionManager1.AddSeparator( ActionManager1.FindItemByAction(FileExit1) );
  iFileAction := TCustomAction.Create( self ); // we want to put in same collection
  iFileAction.Caption := 'Fred';
  // etc.. to build what is wanted
  iActionClientItem := ActionManager1.AddAction( iFileAction, iActionClientItem ) ;

  //*********************************
  // Build sub menu (from Fred) - stage 1 add the visual element - a new action bar
  iChildMenu := ActionManager1.ActionBars.Add;
  iActionClientItem.ChildActionBar := iChildMenu.ActionBar;

  // we add a dummy entry that we can build from.
  // We could set the properties manually, but when we use the action manager
  // it does that automatically, so it is easier just to set this item to not visible
  // then use action manager to do the rest.
  iSubMenuItem := iActionClientItem.Items.Add;
  iSubMenuItem.Visible := FALSE;

  // Now the real build...

  iFileAction := TCustomAction.Create( self ); // we want to put in same collection
  iSubmenuItem := ActionManager1.AddAction( iFileAction, iSubMenuItem );
  iSubmenuItem.Caption := 'Fred 1';
  // etc

  iFileAction := TCustomAction.Create( self ); // we want to put in same collection
  iSubmenuItem := ActionManager1.AddAction( iFileAction, iSubMenuItem );
  iSubmenuItem.Caption := 'Fred 2';
  // etc
end;

striderx 21. Sep 2020 09:52

AW: MainMenu ownerdrawn vs. Styles
 
Das sieht ein wenig gruselig aus. Und das Ganze dann für ca. 80 MenuItems nur um die Schriftgröße anzupassen - nee.

Aber vielen Dank!


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:08 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz