Button and disabled icon
Button and disabled icon
HI again,
If a use icon with commandbutton and set the enabled property to false then icon with index 3 is used from the image list?
So I must create disabled "gray" icon my self and add it to the image list with index 3?
Regards,
Meelis
If a use icon with commandbutton and set the enabled property to false then icon with index 3 is used from the image list?
So I must create disabled "gray" icon my self and add it to the image list with index 3?
Regards,
Meelis
Re: Button and disabled icon
Hi,
yes, this is correct.
Regards
TiKu
yes, this is correct.
Regards
TiKu
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: Button and disabled icon
I don't get it.
The definition is CommandButton.IconIndex([controlState As Long = -1]) As Long.
I thought it goes like this:
The definition is CommandButton.IconIndex([controlState As Long = -1]) As Long.
I thought it goes like this:
- There is a single hImageList for the control.
- IconIndex (without arguments, controlState = -1) uses the index provided as the default control icon.
- IconIndex(3) means that it will use the index provided as the disabled icon.
Re: Button and disabled icon
Are you setting the UseImprovedImageListSupport property to True? I had to implement it this way to not break existing applications.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: Button and disabled icon
Yes.
The icon changes if I change IconIndex for the default controlState. It doesn't work for controlState = 3 and Enabled = False. Instead, it shows the default icon a bit fainted.
Here is a sample, to make it clearer:
Omitting the .IconIndex = <default icon> statement will make the button use the icon at index 0.
The icon changes if I change IconIndex for the default controlState. It doesn't work for controlState = 3 and Enabled = False. Instead, it shows the default icon a bit fainted.
Here is a sample, to make it clearer:
Code: Select all
With CommandButton1
.hImageList = <some image list handle>
.IconIndex = <default icon>
.IconIndex(3) = <disabled icon> 'This is ignored
End With
Re: Button and disabled icon
Try this code:
This way it works for me (Windows 7 SP1)
Code: Select all
With CommandButton1
.UseImprovedImageListSupport = True
.hImageList = <some image list handle>
.IconIndex = <default icon>
.IconIndex(3) = <disabled icon>
End With
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: Button and disabled icon
Hmm. This is very interesting.
I was working with classic theme. After switching to aero, it worked as expected.
This is definitely a bug, although I don't know if it is your code or windows fault.
Also, while on classic theme, I noticed that, if a button has icon+text and Enabled = True, the icon is "almost" hidden:
I was working with classic theme. After switching to aero, it worked as expected.
This is definitely a bug, although I don't know if it is your code or windows fault.
Also, while on classic theme, I noticed that, if a button has icon+text and Enabled = True, the icon is "almost" hidden:
Re: Button and disabled icon
Interesting. You are right. I never noticed this. I'll try to find out whether anything can be done about it.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: Button and disabled icon
The problem is that the native button control does not query for the disabled image if classic theme is used. Instead it always queries for the normal image. It would be quite difficult to work around this behavior in a reliable way.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: Button and disabled icon
Ok. So this is a windows-related bug. I could write a procedure that changes the default icon whenever I want to enable/disable a button, instead of just setting Enabled = True/False. This is an inconvenience but I want to cover the classic theme scenario.
Also, what about the almost-hidden-icon bug? Is there a workaround for this?
Also, what about the almost-hidden-icon bug? Is there a workaround for this?
Re: Button and disabled icon
So far I could not reproduce this problem. Do you have a sample project? It might have to do with the color of the icon's top-left pixel.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: Button and disabled icon
I found out why I had this problem.
I did a hack, in order to show the icon to the left of the text (not the left edge of the button).
Specifically, I set IconAlignment = 4 (Center), I calculate the IconMarginRight, based on the button's text and then I pad some spaces to the left of the text.
With themes it works fine. Without themes the icon seems almost blank (like in the picture a few posts ago).
Apparently, when using themes, the text is drawn transparent and my hack works as expected, while on classic theme, the text covers the icon entirely.
I don't have WinXP to try it, btw.
I did a hack, in order to show the icon to the left of the text (not the left edge of the button).
Specifically, I set IconAlignment = 4 (Center), I calculate the IconMarginRight, based on the button's text and then I pad some spaces to the left of the text.
With themes it works fine. Without themes the icon seems almost blank (like in the picture a few posts ago).
Apparently, when using themes, the text is drawn transparent and my hack works as expected, while on classic theme, the text covers the icon entirely.
I don't have WinXP to try it, btw.