Firemonkey - Combobox highlight item at mouse position - delphi

Nearly every application will highlight a comboboxes' item at the current mouse position.
In Firemonkey Embarcadero changed this behavior.
Image1:
In this case ListBoxItem3 should be highlighted - but it isn't.
I then selected ListBoxItem2 and opened the combobox again.
Image2:
ListBoxItem2 keeps being selected even tho ListboxItem4 should be.
As you can see I was using TListBox Items in this example.
In the StyleBook I added a new StyleObject (a blue rectangle) with a TFloatAnimation so i could add a "fake" selection.
But it sadly didn't work.
Image3:
So here i am after spending quite some time trying to figure out how to select a comboboxes' item on mouse over movements.
Someone know a way to achieve this?

This is a new behaviour introduced by new versions (from X3 onwards), you can set DropDownKind = ddkCustom (default value ddkNative) for emulate old behavior.
Note that using Custom as DropDownKind you obtain a behaviour that it's slightly different from the previous one, since it sets the itemIndex property value immediately, but it shouldn't be a big problem ...

Related

Positioning of custom list box item components in Delphi XE5, Firemonkey

I've customised the style of a Firmeonkey list box item in such a way that now it can consist of 4 TLables in it. Each of the lable has Alignment as alNone.
I'm setting position of each of them in my code whenever i need to add any item. I've observed that when my list has scroll bar and if first component is not visible (i.e. i've scrolled down enough) at that time if i re-add all the items again in list box, then the position of TLabels in first items (or items which are not shown) get distorted.
For setting positions I am using below code :
(tmpListBoxItem.FindStyleResource('txtCol2') As TLabel).Position.X :=
(tmpListBoxItem.FindStyleResource('txtCol2') As TLabel).Position.X + (tmpListBoxItem.FindStyleResource('txtCol2') As TLabel).Width;
Any suggesstions, how can i overcome this issue.
Regards,
Padam Jain
Firemonkey styles are repeatedly 'applied' and 'freed' as components appear and disappear from screen.
It is not enough to simply set properties of style objects once and expect those values to be remembered. What you need to do is either listen to the OnApplyStyleLookup event or override the ApplyStyle method of a custom component and use the same you have above to set the properties again.
This means you'll need somewhere to store the values you are going to set.
I would suggest for your situation that you subclass TListBoxItem so you can add suitable properties or fields and put your code in ApplyStyle.

TRadioButton dropped on TListBoxItem behaves erratically when scrolled

I am trying to implement a Firemonkey TListbox that has a number of TListBoxItems. On one of the TListBoxItems I have placed a number of TRadioButtons by simply dropping them on the TListBoxItem at design time. When the application is run the visual appearance of the buttons is erratic when the TListBoxItem is scrolled off the screen and back on.
Another TListBox question here at StackOverflow makes the point that a TListBox does not host any item other than a TListBoxItem. That being said, there seems to be no such restriction that I can find about a TListBoxItem. I have routinely placed TEdit, TLabel and TComboBox components in this manner without difficulty.
To duplicate the condition start a new Firemonkey desktop application; drop a TListBox on the form and set it to alClient; populate the TListBox with a number of TListBoxItems; set the heights of the TListBoxItems or Form so that when run, you are able to scroll the TListBox; drop three TRadioButtons on the topmost TListBoxItem; set the GroupName for all the TRadioButtons to the same name; run the application; select a TRadioButton so that it appears selected; scroll the TListBox so that the TListBoxItem containing the buttons scrolls off the form; scroll back; continue selecting different TRadioButtons and scrolling until anomalies are observed.
Questions: First and probably most important, am I permitted to simply drop components on a TListBoxItem at design time? Has my previous success with this technique been simply accidental?
Second and also of importance for an application I'm working on, if this is NOT a viable approach to my UI, can anyone suggest better approaches?
TIA
I entered a Report at Embarcadero's Quality Central and after a few exchanges with Tomohiro-san along with Marcus Adams suggestion that the problem is related to scrolling came up with the following:
Tracking through the various cases mentioned it appears that there are a number of other cases that are related to this one because of the use of scrolling. When an item is scrolled off the screen and then scrolled back the system apparently reapplies the styles to the items being returned to visibility. At least, in the few cases I have traced that seems to be the case. It is on this reapplication of style and rendering that the problem seems to occur. In my own examples I have added a button that displays the IsChecked property for the controls and the rendering does not reflect the property correctly in all cases, suggesting that it is the style/rendering that is causing the issues.
The related issues I was able to find are:
QC 120593
QC 117381
QC 119638
QC 117658
I'm waiting for a resolution.
I ran into the same problem. I found no solution, but as a work-around, I ended up just replacing the radio buttons with check boxes and adding code so that they behaved in a similar manner to Radio buttons. E.g., only allowing one of a group of check boxes to be selected...

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.

How to set the glyph for a toolbar button to blank?

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.

Cause 'hint' to refire on listview as I move over items

Sure I've seen this done before but off-hand I can't find any examples.
I've got a TListView, set in 'report' viewstyle. It has about half a dozen subitems, and one thing we'd like to do is have the 'hint' (tooltip) on the listview dynamically show another field of data. That is, each time you move the mouse over any given row, the 'hint' would show some text relevant to that particular row.
I'm partway there - I can do this using the OnInfoTip method, but unfortunately once a tip has appeared, Windows seems to decide that I don't need to see a hint for the listview again until I move the mouse away from the listview and then back 'over' it again. Simply moving the mouse down to the next row, all-the-time keeping the mouse over the control, doesn't persuade the program to display the new hint.
Just to be clear - I've got OnInfoTip working so that the program does display the right hint relevant to the item I first moved the mouse over. Changing the hint text isn't the issue. The problem is that moving the mouse to another item in the listview doesn't cause the software to show a new hint. (Hope that makes sense).
Is there some proper way of getting this behaviour to work, or am I going to end up doing something icky with mouseovers and then manually drawing a hintbox (etc)?
check the following link:
Display Custom Hints for TListView Sub Items
Edit:
I just checked it now on delphi7 it's showing the hint for every row dynamically after moving the mouse on the listview.
Offtopic: This is simple in Virtual Treeview component, it is build-in feature.
i was using the OnInfoTip event (i didn't need hints for the subitems). the hint was "flashing" (show/hide/show/hide/show/hide/show/hide). found the listview's ShowHint was false. set it to True and it worked as it should.

Resources