dormky 2 Posted July 17 (edited) (These are TBitBtns) In the first image, all buttons are enabled. In the second, the bottom two are disabled. It seems that the disabling makes every color except for pure black completely disappear (see the grey at the top of the pencil disappeared too). What can I do to prevent this ? The icon should just be greyed out, not entirely disappear. I don't want to make greyed out glyphs and switch them around for literally every button in the program either. Although if it comes down to it, I guess I could always have a custom button that takes the existing glyph and greys it ? But that sounds finicky and there's probably a better way of solving this. Thanks ! Edited July 17 by dormky Share this post Link to post
Uwe Raabe 2051 Posted July 17 If you use the Glyph property of TBitBtn, this will indeed be quite tedious. The preferred way is to use the Images property to assign an image list and set the ImageIndex/ImageName and DisabledImageIndex/DisabledImageName to the proper icon. There are also such properties for the Hot, Pressed and Selected states. 1 Share this post Link to post
dormky 2 Posted July 17 Such a shame. It seems the Images property only exists for TButton. I've tried adding my bitmap to the property but it doesn't seem to work like the Glyph property (double click to edit). How am I supposed to add it ? Share this post Link to post
Attila Kovacs 627 Posted July 17 Use TImageList, ideally a descendant that can handle SVGs. Share this post Link to post
Die Holländer 34 Posted July 17 (edited) The JVCL has a JvXPButton.. Maybe you can change the buttons by editing the *.dfm file of the Form.. 😬 Edited July 17 by Die Holländer Share this post Link to post
Uwe Raabe 2051 Posted July 17 35 minutes ago, dormky said: It seems the Images property only exists for TButton. Probably depends on the Delphi version you are using. Share this post Link to post
PeterBelow 238 Posted July 17 4 hours ago, dormky said: (These are TBitBtns) In the first image, all buttons are enabled. In the second, the bottom two are disabled. It seems that the disabling makes every color except for pure black completely disappear (see the grey at the top of the pencil disappeared too). What can I do to prevent this ? The icon should just be greyed out, not entirely disappear. I don't want to make greyed out glyphs and switch them around for literally every button in the program either. Although if it comes down to it, I guess I could always have a custom button that takes the existing glyph and greys it ? But that sounds finicky and there's probably a better way of solving this. Thanks ! Do you know that you can supply up to four images in the bitmap you use for the Glyph property? See here for what they are used for. If your bitmap only contains one glyph image the control will synthesize the disabled image from it and the results are often not that good. Share this post Link to post
Die Holländer 34 Posted July 17 4 hours ago, dormky said: (These are TBitBtns) I don't want to make greyed out glyphs and switch them around for literally every button in the program either. Share this post Link to post
corneliusdavid 209 Posted July 17 8 hours ago, dormky said: Such a shame. It seems the Images property only exists for TButton. I've tried adding my bitmap to the property but it doesn't seem to work like the Glyph property (double click to edit). How am I supposed to add it ? What is "such a shame"? Perhaps you're just unfamiliar with current best practices? There are many components that use the Images property: TBitBtn TSpeedButton TCategoryPanelGroup TMainMenu TActionList TTabControl TPageControl And many more. Plus, many third-party components use this property as well. It's far more versatile than the old Glyph property. Search for articles and YouTube tutorials--you'll find plenty of information. 1 Share this post Link to post
dormky 2 Posted July 18 21 hours ago, PeterBelow said: Do you know that you can supply up to four images in the bitmap you use for the Glyph property? See here for what they are used for. If your bitmap only contains one glyph image the control will synthesize the disabled image from it and the results are often not that good. Yes, but doing this for every icon in this 1M lines project does not make sense if there is another solution out there. Especially as greyed out an existing image is not complicated in itself, it's just the implementation in TBitBtn that's faulty. Share this post Link to post
dormky 2 Posted July 18 15 hours ago, corneliusdavid said: What is "such a shame"? Perhaps you're just unfamiliar with current best practices? There are many components that use the Images property: TBitBtn TSpeedButton TCategoryPanelGroup TMainMenu TActionList TTabControl TPageControl And many more. Plus, many third-party components use this property as well. It's far more versatile than the old Glyph property. Search for articles and YouTube tutorials--you'll find plenty of information. It is a shame that TBitBtn's method of greying out an icon is to make black grey, and every other color white. That is not a good method imo as it leads to problems like this in this post, forcing the developer to put in more work (re-implementing the greying or creating greyed out icons). A UI framework should have correct greying, that's not something up for debate. Share this post Link to post
Die Holländer 34 Posted July 18 1 hour ago, dormky said: Yes, but doing this for every icon in this 1M lines project does not make sense if there is another solution out there. So, why did they/you use this button in the first place and how, after 1M lines, it became suddenly a problem? I would just use the JVCL JvXPButton that will gray out the button as you like. Share this post Link to post
dormky 2 Posted July 18 1 hour ago, Die Holländer said: So, why did they/you use this button in the first place and how, after 1M lines, it became suddenly a problem? I would just use the JVCL JvXPButton that will gray out the button as you like. Those lines were literally written before I was born. Believe me if I could throw it all away I would but alas that's not realistic. Try to explain to management why we'd need so much time and testing to "make the icons grey" :') Share this post Link to post
JonRobertson 67 Posted July 18 2 minutes ago, dormky said: Try to explain to management why we'd need so much time and testing to "make the icons grey" Because every icon in a 1M line project would be affected? Share this post Link to post
dormky 2 Posted July 18 1 hour ago, JonRobertson said: Because every icon in a 1M line project would be affected? A search for TBitBtn just gave me 1842 results, and that's just the "main" part of the program. Now not all of these buttons have icons of course, but a significant portion does. We're talking at least hundreds of buttons to update and check here. So no it's not every icon, but it's still a whole freaking lot. Share this post Link to post
Uwe Raabe 2051 Posted July 18 What Delphi version are you using? TBitBtn supports Images since Delphi 10.4. If by any chance you are able to use one of the more recent Delphi versions, I suggest to use the image list approach. It is way easier to maintain, especially when you plan to support High DPI in the future. 1 Share this post Link to post
JonRobertson 67 Posted July 18 8 minutes ago, dormky said: A search for TBitBtn just gave me 1842 results, and that's just the "main" part of the program. Now not all of these buttons have icons of course, but a significant portion does. We're talking at least hundreds of buttons to update and check here. So no it's not every icon, but it's still a whole freaking lot. You can also search for Glyph.Data in the DFM files. There are components other than TBitBtn that have a Glyph property, but each of those should (I think) be a visual component that has an image stored in the component that would be displayed in the app. I agree with others that you should either replace TBitBtn with a component that accomplishes your goal or switch to using either an image list or TImageCollection and TVirtualImageList. The later would be a better investment of the time required. You may also want to look at High DPI Image List Support. Share this post Link to post
Die Holländer 34 Posted July 18 I wonder how difficult it is to make your own component TMyBitBtn based on TBitBtn and overwrite the way the enable/disable picture works, like how the JvXPButton does it or if disabled then change all the pixels (only 32x32 ?) from color to grayscale in the ondraw. Then modify all the DFM TBitBtn Text to TMyBitBtn.. Share this post Link to post
Lajos Juhász 291 Posted July 18 Sooner or later you will have to rewrite the UI to be more high-DPI friendly. Changing an image should not require a lot of testing. I did that for several "1M" line of code applications without a problem. Yes it requires time, but it is a must for an old application to be able to work on "modern monitors". (A TBitbtn style program I bet looks very outdated) Share this post Link to post