Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Themes and ListBoxes


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Apr 2, 2015 8:38 AM Last Post By: S De Threads: [ Previous | Next ]
S De

Posts: 16
Registered: 5/1/15
Themes and ListBoxes  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2015 1:27 PM
Hi,

I'm running into some strange behavior when I use a Tlistbox with multiselect and have runtime themes enabled.

Here is the problem:
I have runtime themes enabled with a particular style
I have a listbox with multiselect turned on
On the mouse down for the listbox I attempt to set the itemindex to -1 and remove all highlighting when a user clicks on white space where there isn't an item.
--> The line Listbox.ItemIndex := -1 has no effect. The itemIndex remains on the last item in the box.

What I have discovered fixes the problem is if I set runtime themes to NONE on the application appearance section.

A few questions that I have:
- How is it that my application is still able to use different styles (and continues to allow me to change it at runtime) even when I disable the runtime themes? Is it okay for me to run this way? Will I run into any other problems? I guess this is messing with my entire understanding of the themes. I can't believe that the styles still work without the themes enabled... So then what is the difference between enabling/disabling the themes?

- Why is this listbox bug related to the runtime themes at all? In the past my team has run into other issues with listboxes when themes are enabled and so we just didn't use themes. But now our application looks so outdated that we really need to use the new styles.

I'd really appreciate any help you could provide on this subject!

SDE
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Themes and ListBoxes  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 1, 2015 1:57 PM   in response to: S De in response to: S De
S wrote:

--> The line Listbox.ItemIndex := -1 has no effect. The itemIndex
remains on the last item in the box.

When MultiSelect is true, the ItemIndex property getter uses the LB_GETCARETINDEX
message, and the property setter uses the LB_SETCARETINDEX message. These
messages read/set which list item is focused, not which item is selected.

The property getter returns 0 if there is no focused item, and -1 if the list is empty. The
setter checks the value returned by the getter, and if you are assigning a new index that
matches the return value of the getter then LB_SETCARETINDEX is not issued.
Double-check what value the getter is actually returning, make sure it is not already -1.

When MultiSelect is true, use the TListBox.Selected[] property instead to get/set whether
a specific list item is selected. The property getter/setter uses the LB_GETSEL/LB_SETSEL
messages.

- How is it that my application is still able to use different styles
(and continues to allow me to change it at runtime) even when I
disable the runtime themes?

Runtime Themes is a feature of Windows itself. UI controls implemented in
ComCtrl32.dll v6 (which requires a Theming manifest to enable) are drawn
by Windows itself.

Styles is a VCL feature, where the VCL custom-draws UI controls.

Is it okay for me to run this way? Will I run into any other problems?

I guess this is messing with my entire understanding of the themes.
I can't believe that the styles still work without the themes enabled...

Styles are not dependant on Runtime Themes, and vice versa.

- Why is this listbox bug related to the runtime themes at all?

A different system DLL with a different implementation is being used. ComCtrl32.dll
v6 does disable/ignore a lot of standard messages. Maybe LB_SETCARETINDEX
is one of them? Usually affected messages are documented, but the documentation
for LB_SETCARETINDEX makes no mention of this.

In the past my team has run into other issues with listboxes when
themes are enabled and so we just didn't use themes. But now our
application looks so outdated that we really need to use the new
styles.

Then use them. You don't need Runtime Themes to use Styles.

--
Remy Lebeau (TeamB)
S De

Posts: 16
Registered: 5/1/15
Re: Themes and ListBoxes  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 2, 2015 8:38 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thank you so much! I was confusing the windows runtime themes with the Delphi styles/themes. That clears that up. I won't worry about the other issue so much since I don't actually need windows runtime themes for my application and simply by disabling it can avoid the issue entirely.

SDE
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02