UPDATE
This is an old article if you are looking how add vcl styles support to the Menus, dialogs and more try the VCL Styles Utils project.
The TPopupMenu component has not support for Vcl Styles directly, so if you use this control in a form with Vcl Styles enabled you will get a result like this.
To fix this you have 2 ways :
- Write a style hook for a TPopUpMenu (The hard way)
- Or use the TPopupActionBar component (the easy way)
In this post I will show you how use the option 2, taking advantage of two facts
- The TPopupActionBar component has full support for Vcl Styles
- Descends directly from the TPopupMenu component.
So adding the Vcl.ActnPopup unit to your project and using a interposer class (before of the form declaration which contains the PopupMenu), you can add vcl styles to the TPopupMenu component.
uses Vcl.ActnPopup; type TPopupMenu=class(Vcl.ActnPopup.TPopupActionBar);
This is the result after of add the 2 above lines of code.
March 6, 2012 at 4:06 am
Thanks a lot Rodrigo, very helpful well done
March 6, 2012 at 11:41 am
Thanks for your feedback
March 6, 2012 at 4:57 am
Good tip, would it be simpler though to just change the declaration of the TPopupMenu to TPopupActionBar in the .dfm and .pas? Then there is no need for an interposer class.
March 6, 2012 at 11:41 am
Sure, replace the component is a valid option too.
March 6, 2012 at 3:08 pm
Is there a QC report for that omission?
March 6, 2012 at 3:23 pm
François, as far I know there is not QC, report for this.
March 7, 2012 at 4:31 pm
Is there any way to use “something like this” to style TMainMenu?
March 8, 2012 at 1:47 am
I’m working in a workaround just now for skin the popup part of an TMainMenu, in the meanwhile you can use a TActionMainMenuBar component which supports the vcl styles pretty well.
March 11, 2012 at 3:21 pm
Could you show me example, please?
March 12, 2012 at 5:34 pm
My comment means that you must use a TActionMainMenuBar component instead of a TMainMenu. Exist several samples of using this component in the internet.
April 10, 2012 at 8:54 am
The trick with the TPopupActionBar instead of the TPopupMenu has one flaw: if one menuitem of the menu is set to default:=true, then the application crashes with a stack overflow when trying to show the menu. This only happens if you change the VCL style.
Does this happen to anyone else than me?
April 10, 2012 at 1:23 pm
This is a bug of the TPopupActionBar component, and is not related to the vcl styles (the bug occurs even in a plain vanilla app with a TPopupActionBar and no vcl styles enabled). you must report this to the QC page http://qc.embarcadero.com/
April 11, 2012 at 5:03 am
Done in http://qc.embarcadero.com/wc/qcmain.aspx?d=104809.
May 30, 2012 at 7:37 am
Hi Rodrigo. I have a doubt about using VCL Themes.
When i use themes, it looks like some of my custom modifications gets overriten.
An example would be the ‘Font Color’ of my DBEdits. I had set it to BLUE and when i use styles, it just goes BLACK. Is there an workaround about this?
att,
May 30, 2012 at 11:19 am
Try this post https://theroadtodelphi.wordpress.com/2012/02/06/changing-the-color-of-edit-controls-with-vcl-styles-enabled/
October 2, 2012 at 5:31 pm
Hi
Right To Left direction not supported in this method!!!
March 19, 2013 at 10:34 pm
Why “AutoHotkeys:= maManual”invalid?Thanks
April 17, 2013 at 12:50 pm
Can you explain your comment?
May 5, 2013 at 9:08 pm
PopupMenu1.AutoHotkeys:= maManual;
//add 2 menu item ‘复制’,’粘贴’
//But the menu item still show hot keys,like this ‘复制(X)’,’粘贴(Y)’…
January 16, 2014 at 9:49 pm
Check this post https://theroadtodelphi.wordpress.com/2014/01/16/vcl-styles-utils-and-popup-menus-major-update/
August 2, 2013 at 1:55 pm
Thank you Rodrigo for this.
Is there a way to make the TMenuItem Break property work too?
Using this trick that property is just ignored.
I guess the “Hard way” is needed for this.
January 16, 2014 at 9:50 pm
Check this post https://theroadtodelphi.wordpress.com/2014/01/16/vcl-styles-utils-and-popup-menus-major-update/
October 23, 2013 at 3:25 am
HI,
I’m also interested in the MenuItem Property Break and the property Bitmap. Both will be ignored if i use the interposer class TPopupActionBar. Is there a simple way to handle this or do i have to write my own TPopupMenu StyleHook?
January 16, 2014 at 9:50 pm
Check this post https://theroadtodelphi.wordpress.com/2014/01/16/vcl-styles-utils-and-popup-menus-major-update/
Pingback: VCL Styles Utils and Popup Menus – Major Update | The Road to Delphi - a Blog about programming