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).
Related
In my program, the image of SpeenButton set by imagelist. I need the image change with another image in the imagelist, when I click the speedbutton. How can I do that?
In case you are talking about VCL TSpeedbutton, you can place a TActionList on your form and connect it to your TImagelist. Then create an action in the actionlist, set its ImageIndex to the desired image. Now connect the TSpeedbutton to that action. In the OnExecute event of the action change the actions ImageIndex property to the new value. The speedbutton now shows the new image.
I've created a style with the Bitmap Style Designer for Delphi XE7.
I've updated the button style to white with a blue border and duplicated it to create an orange button called Button_Copy.
I've exported the style to FireMonkey, but I can't find Button_Copy to assign it to a button on my form. How do I do this?
Also, can I rename Button_Copy to e.g. OrangeButton?
In the Bitmap Style Designer, save the style as a FireMonkey style.
Add a TStyleBook to your form.
Set the StyleBook property to the stylebook.
Double-Click the StyleBook and open your style. Close and Apply.
You can now set the StyleLookup property of a button to Button_Copy and if all is well you will see your new style.
Note that your new style won't appear in the selection list for StyleLookup - the list of available values appears to be hard coded.
And, of course you can change the name - just change the StyleName property of the top level object (probably a TLayout). The normalnaming convention is to append the word 'style', e.g. OrangeButtonStyle.
When using a TListView and themes are disabled in the Application, the focused and selected item appears something like this:
Notice in both images where the triangle is. The painted box for the item does not draw where the icon appears. In a TListBox the painted item fills the whole selected item.
How might I be able to get the icon part of the selected item to fill, just as it does with the text part?
I know TListBox renders like this, but I require the use of TListView for the Data property, also the TListView handles icons better via a TImageList.
Thanks.
You'll need to use the OnCustomDraw events of TListView. Within the event handler:
Determine if the item is selected
Determine if the control is focused
Draw the appropriate selection rectangle if the item is selected (grey if the control isn't selected, blue if it is)
Draw the text
Draw the image from the imagelist using TImageList.Draw
There are methods for doing these things, such as DrawText and FillRect.
Note that you can use TListBox rather than TListView if you'd rather. You indicated you need the Data property for items in the list, I'd assume to tie them up to your actual model objects. You can do this with anything that supports TStrings (such as TListBox.Items) using TStrings.Objects.
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.
I add a toolbar with some standard Delphi components to my application. Unfortunately, the stupid arrow is first glyph (does anyone even know what it is for?)
I would like to destroy it totally, or, at least, set itcs icon to blank, so that it blends in with the toolbar.
How can I do this?
I need some code which can be executed twice without causing an exception. Thanks
TToolButton gets its image from combining its ImageIndex property with the enclosing toolbar's Images property, which refers to a TImageList. To make a toolbar button have no image, assign ImageIndex := -1.
To remove the glyph from a TSpeedButton at design time, select the button, and then select the Glyph property in the Object Inspector. Press Del to clear the property. To do the same at run time, assign Button.Glyph := nil.
If you have a pre-made toolbar, such as TMediaPlayer or TDBNavigator, then you can't customize the buttons. They always show the arrow glyphs that are hard-coded in the control. You can choose to hide or show certain buttons, though. If you placed the control just to get a row of buttons and have no intention of using them to play media or navigate a database, then don't use that control. Just place a TPanel and put standalone buttons on it.