TPopupActionBar has no ColorMap property? - delphi

Ok, so I almost have a good looking UI, using TActionManager, TActionMainMenuBars and TToolBar with DrawingStyle as gradient to create a OfficeXP style interface.
I am using a couple of TPopupActionBar popup menus too, but I dont see a ColorMap property. I am using a ColorMap property to change the color of the default XP style color, and also changing the Hot Color of the TToolBar to match the menu.
I now need the TPopupActionBar popup menu to match the menu and toolbar, but how can I do this when I see no way of assigning a ColorMap to it?
Excuse me if this is non trivial, I have looked and cannot see. I also tried at runtime to assign a ColorMap but there doesnt seem to be the property for it?? I can change the Style of the TPopupActionBar, but cannot assign a ColorMap.

To assign a ColorMap you can use the OnGetControlClass event of the TPopupActionBar component , then check if the PopupMenu is not nil and finally assign the nested property ColorMap of this property.
check this sample.
procedure TFormMain.PopupActionBar1GetControlClass(Sender: TCustomActionBar;
AnItem: TActionClient; var ControlClass: TCustomActionControlClass);
begin
if Assigned(PopupActionBar1.PopupMenu) then
PopupActionBar1.PopupMenu.ColorMap:= TwilightColorMap1;
end;
check this image which contains a TPopupActionBar with the TwilightColorMap applied

Related

Change the selection opacity of a ListBox

I have trouble changing the selection opacity of the FireMonkey ListBox. In my case I wanted to change the color of the selection, and make it fully opaque. At first I tried to do this by changing the style of de ListBox through a custom style based on the default. The selection part is a TStyleObject with an opacity of 1. I replaced it with a TRectangle filled with the color Red. After I applied my style I noticed that the selection was not the same bright red color that I chose for the selection.
So I just dove into the FMX.ListBox code to see what is happening there. To my surprise I found that the opacity of the selection is set to 0.7 hard-coded in the TCustomListBox ApplyStyle procedure. I expected that the style was responsible for how things looked. I don't know if it's the wrong way to think about it, but this is not what I expected.
After this I tried changing the selection opacity run-time by implementing the OnApplyStyleLookup event with the following code.
procedure TForm1.ListBox1ApplyStyleLookup(Sender: TObject);
var
SelectionControl: TControl;
begin
if ListBox1.FindStyleResource<TControl>('selection', SelectionControl) then
SelectionControl.Opacity := 1;
end;
This however has no effect. I tried to do the same thing in a new custom ListBox control by deriving from TCustomListBox and overriding the ApplyStyle method where after the ApplyStyle of TCustomListBox through the inherited keyword I placed the code to set the selection opacity to 1. This too did not have any effect.
Am I just going about this the wrong way, am I missing something, or is it just Delphi being weird.

How to dynamically change TChart's Panel's color in Delphi?

While in IDE Panel's parameters are shown in Chart->Panel->Parameters (e.g. color). I can't use this method in code though: Chart.Panel.Color:=RGB(0,0,0);//doesn't work Any advice would be appreciated.
Use the Color property, e.g., Chart1.Color := clYellow.

How to change caption font color on TCheckBox, TRadioButton, TGroupBox?

I don't know what my problem is, but I cannot set the font color in DEx2 for controls like TCheckBox, TRadioButton, TGroubBox, and TRadioGroup. It doesn't matter if I do it in the IDE or programmatically.
I have set my form color to clBlack and want my captions to be clWhite, but they won't render any color but clBlack. When I assign a color on a form's OnShow event and step through it in the debugger, it shows the value I assigned it, but on the screen it is still black.
I am not using styles or anything else. Any ideas?
Here is a sample form:
white on black example http://www.skippix.us/temp/Delphi-Font-Problem.bmp
When you uses the windows themes in an application, most of the custom settings like the font colors are ignored. As workaround and depending of the component you can ownerdraw the control (only when this feature is supported), override the paint method in order to use your own color in the font (TRadioGroup, TGroupBox), and for components like TCheckBox and TRadioButton (which are WinAPI controls wrappers) you must intercept the WM_PAINT windows message and implement your own code to draw the control.
Also starting with Delphi-xe2 you can use the vcl styles which allow you to change the appearance of the controls, from here (and when is possible) you can modify the style hooks to apply your own font colors and other customizations.
A simple and easier workaround is to create a checkbox without caption and add a label after it. You can easily change the label's color. You can also create a new component that binds a label to the checkbox itself. That's what worked for me on Delphi 2007.
It will work under the following setting:
Project Options > Application > Runtime Themes = none

How to change TBitBtn back color?

I need to change TBitBtn's back color. Please suggest me the way to change it.
You can't.
You might replace your BitButton to another button component that implements this property.
One simple and quick solution is to replace each of your BitButton with a pair SpeedButton/Panel. Set SpeedButton's Flat property to False; set Panel's BevelInner and BevelOuter to None; and carefully arrange the SpeedButton over the Panel. Then you might change the Panel Color property and it will appear like Button's color has changed. There is some change in functionality, as SpeedButtons can't get Focus; this may prevent its usage for you or might be a premium indeed, test and decide.

How do I make the Object Inspector show more TColor property values?

The IDE Object Inspector shows TColor properties with a drop-down ColorBox, and the color can be selected by name - clBlack etc, as defined in the Graphics unit. The problem is that the clWeb colors also defined in the Graphics unit are not present, and any custom colors I define are also not there.
So how do I extend the defined colors that are selectable in the Object Inspector?
PS Delphi XE
I would try to derive a class from TColorProperty (unit VCLEditors) and override GetValue/GetValues/SetValue. See here for a detailed discussion.
Edit: My original link is broken by now. Try the thread Custom colors in Delphi 7 (in borland.public.delphi.vcl.components.writing.general) instead.

Resources