How to add thumb images to TRzGroup Item Menus - delphi

I am creating sidebar images with the help of TRzGroup. I already have created TRzGroup with caption Print Now and added item named Print to it. I am planning to add a small printer icon image at the left hand side of the menu item as shown in figure at bottom. How it can be done ?
object RzGroup2: TRzGroup
Items = <
item
Caption = 'Print'
ImageIndex = 4
OnClick = RzGroup2Items0Click
end>
Opened = True
OpenedHeight = 47
DividerVisible = False
SmallImages = ImageList1
Special = True
Caption = 'Print Now'
ParentColor = False
end
While this code is extracted from somewhere in the code SmallImage attribute is assigned to ImageList1. I assume it is for image menu. I checked at object inspector there is SmallImages property but not sure how to create ImageList1 and assign to SmallImages.

Drop a TImageList from the Delphi component palette (Win32 page) onto your form (or in a data module used by the form). Double-click that new TImageList, click the Add button on the ImageList Editor that appears, and add images. Close the `ImageList Editor'.
Go back to your form. Click on the RzGroup2 item, and drop down the list in the Object Inspector for the SmallImages property, and choose the imagelist you added in the first step.
Set the ImageIndex of the Print item to the appropriate index in the ImageList you assigned to the RzGroup in the previous step.

Related

Implementing ImageIndex property editor in my FMX component

I am designing a FireMonkey Component with TImageList and TImageIndex published properties. I can easily select a TImageList from the dropdown of the ImageList property, and the ImageIndex property seems to know that it should pick an image (it shows an icon next to the number), but there's no images in the dropdown for this property (only for -1), and the icon for the (manually entered) ImageIndex value (0) is shown as a "no icon" image (the same as for -1 in the dropdown):
From the source (FMXReg.pas) it seems like I should call a line like this in my Register procedure:
RegisterPropertyEditor(TypeInfo(TImageIndex), MyControl, '', TImageIndexProperty);
but I can't find TImageIndexProperty anywhere.
The component works - it selects the proper image from the ImageList as defined by the ImageIndex property, even if I can't use the drop-down box (ie. if I enter the ID number manually).
How do I implement a proper ImageIndex property editor for my FireMonkey control? How do I tell it to look up the Images in the ImageList property?
(and yes: there are images in the ImageList, which I have verified by attaching the same ImageList to a standard TButton, and here the ImageIndex dropdown works without problems).

How select TComboBox item on Mac with Firemonkey?

I have a TComboBox with several Strings in its Items list. When run on Windows, this works properly - I am able to click the combo-box, have the items appear, and then select one of the items.
When I set the OS target to OS X, however, the TComboBox does not allow me to select an item. I can click the TComboBox and have the items appear, but when I try to click an item from the drop-down list I receive a 'bump' sound on the Mac, and nothing is selected.
How can I get TComboBoxes to work properly on the Mac using Firemonkey?
I am using C++ Builder XE6 with FMX (Firemonkey).
Workaround:
Basic idea: use Show () instead of ShowModal (), combined with a component that will make the main form non-clickable while the child form is shown.
On the main form, add a TRectangle (or TPanel) with Visibility = false, Opacity = 0.25 (or something like that - could also be 0), and HitTest = true.
Then, when about to show a child form, call a function that sets the TRectangle on the main form to cover the main form (setting its Position->X, Position->Y, Width, Height) and then sets its Visibility = true.
Then, call a child form with Show () instead of ShowModal ().
When the child form is done, call a function on the main form that sets the TRectangle back to Visibility = false.

Delphi 2010 image on Tbutton fading/blinking

When I set the imageindex and images property of a Button (from a imagelist component/pngs), start the program and click the button, the image is blinking slowly/ fading in and out. How to prevent this and what seems to be the problem?
Reviving an old topic...
After searching for a solution on internet and found nothing, I took a look in the TCustomButton code.
It happens that, internaly, a button control on Windows has an imagelist with 6 images, as follows:
index 0: normal image
index 1: hot image (when mouse is moving over button)
index 2: pressed image (while you hold the mouse button d own)
index 3: disabled image
index 4: selected image (when the button has focus, but is not pressed nor with mouse over it)
index 5: (the one that we need and can't be specified in TButton control; we'll talk about it)
In the TButton control in Delphi, you can set an ImageList to the "Images" property, and you can set "ImageIndex", "HotImageIndex", "PressedImageIndex", "DisabledImageIndex" and "SelectedImageIndex".
With this properties set, the TButton control creates ANOTHER image list, and copy the indexes you specified in the properties from the image list in the "Images" property to that new created image list, in the order I specified above.
The problem is, when you focus the control, Win 7 Aero has that effect that it fades in and out the highlight color (a little animation), and it used the 6th image from it's internal image list to fade in and out to also, but it is IMPOSSIBLE to supply that "FADE" image index to TButton control, so I have created a simple solution that is working for myself, but I have to call in RunTime. (you could derive a new class from TCustomButton and create a new control that you can set a new SelectedFadeImageIndex for example, but I didnt).
I created this procedure:
procedure MakeButtonImageStopBlinking(AButton: TCustomButton);
var
ButtonImageList: TButtonImageList;
Icon: HICON;
begin
SendMessage(AButton.Handle, BCM_GETIMAGELIST, 0, LPARAM(#ButtonImageList));
Icon := ImageList_GetIcon(ButtonImageList.himl, 0, ILD_NORMAL);
ImageList_AddIcon(ButtonImageLIst.himl, Icon);
DestroyIcon(Icon);
end;
so, when the window is created (on OnCreate event), i just call MakeButtonImageStopBlinking suppling each button that has image as it's parameter, and it all now works.
Sry for revving such an old topic, but it seems to be no answer for that anyware (or I wasn't able to search properly).
Edit: Setting DoubleBufferd to True will work, but it will stop the little animation from the button with focus. With the solution above, you can leave DoubleBuffered to False and you'll get it all (animation from aero and no fading out image).
It appears to be a doubleBuffered property of a Tbutton. When set to false, the image blinks, when set to true it's working. This occurs on Win 7 with aero enabled.

delphi 2009 accelerators

How to remove the Accelerators from TMainMenuActionBar ?
can't seem to find the AutoHotKey = maManual property to change, nor to find any other property that will cause the right effect.
(Assuming the question is about TActionMainMenuBar) you would set the AutoHotKeys property through the ActionManager component that the action bar is linked to (through its ActionManager property). Unlike the TMainMenu's AutoHotKeys, this one is a boolean property.
To set the property at design time,
Select the 'ActionManager' component on the form
Click the ... button on the right side of the ActionBars property in OI.
Select your MainMenuBar from the popped up Editing ActionManager1.ActionBars' dialog.
Click the ... button on the right side of the Items property in OI, which will launch the Editing ActionManager1.Items dialog
Do not select any of the items at this time. Instead, set the AutoHotKeys property to True or False in OI.
At run time you can do:
ActionManager1.ActionBars[0].Items.AutoHotKeys := False;
Note that you might need to re-set the Caption of an Item after toggling AutoHotKeys. I.e. 'F&ormat' -> 'Format'.

Strange popup menu issue

I'm using delphi 2009 and have created a popup menu.
object PopupMenu1: TPopupMenu
object lmm1: TMenuItem
Caption = 'lm/m'#178
end
end
as soon as i have a "²" in a popup menu, it'll appear as "lm/m²(L)". using maManual for AutoHotKeys doesn't help...it still appears the same way. it's like hotkeys because each menu item gets a new one.
"lm/m² (L)"
"m/m² (M)"
"am/m² (N)"
"bm/m² (O)"
must i use "lm/m2" instead of "lm/m²" if i want the (L) to go away?
used internationally, i'd still expect the "²" would be displayed properly.
thank you for your help!
here's the solution i devised after studying/debugging the source of the TMenuItem.InternalRethinkHotkeys and TMenuItem.GetAutoHotkeys:
object PopupMenu1: TPopupMenu
Left = 184
Top = 272
object MenuItem1: TMenuItem
AutoHotkeys = maManual
Caption = 'lm/m'#178
end
end
The AutoHotKeys property applies to keyboard accelerators when the ALT key is held down. What you are seeing is the TMenuItem.ShortCut property at work instead. Make sure it is set to scNone for any item you do not want "(#)" to appear on.

Resources