hello everyone.


hello everyone.

I was playing with Delphi XE6 and found something interesting: TButton does not apply the color property. Font style, size, pitch, etc. shows ok but why the color isn't applied?

TBitBtn works ok. But I don't want to use this component. i want to keep my apps clean and simple.

I don't know if that is a bug or something else must be done to apply the color.

if anyone knows about this issue, feel free to comment ;)

Comments

  1. I believe windows handle the font color. if you want to change it, you need to override the Paint for the control creating a new class.

    http://stackoverflow.com/questions/10513628/delphi-changing-the-button-color-using-a-class-helper

    ReplyDelete
  2. but why only the color? and not all the font proprieties?

    ReplyDelete
  3. That is to be expected and it's been this way since XP themes were introduced around 13 years ago. The theme API handles visual appearance for Win32 controls.

    ReplyDelete
  4. Hmm, good question, we can blame the embarcadero staff i guess because, actually windows handle everything, but delphi create override methods for some properties( font color not included ?).

    I do not know if I'm right, I'm just guessing.

    ReplyDelete
  5. Alan Patric No, Emba got it right. It's just reflecting the underlying platform.

    ReplyDelete
  6. TButton is in Standard palette of controls not in Win32, and why only the color doesn't work?
    I have tried to change the color of 3D Objects in windows theme and all my application look green :). Not working in Aero Themes in Win7

    ReplyDelete
  7. Is the color of the button set to clBtnFace ?

    ReplyDelete
  8. Pacurariu Stelian The VCL TButton is a loose wrapper around the Win32 BUTTON control. The control itself is implemented by the system. It is documented here: https://msdn.microsoft.com/en-us/library/windows/desktop/bb775943.aspx

    The fact that VCL controls like this are wrappers of native platform controls is what allows an application to pick up the underlying theme of the system. You can contrast this with the FMX approach where all controls are drawn by the FMX library and whenever new versions of iOS, Android, Mac OSX and Windows are released with new themes, update style packs are needed for FMX packs to emulate those new themes.

    ReplyDelete
  9. So, if you want more control over the visual appearance of your controls then you should consider VCL styles or FMX.

    ReplyDelete
  10. that is not the point... using some methods we can make the text color in TButton to look green and I don't really care if the text color of the button is green or not. But why on earth they include the color propriety if when you change the propriety it has no effect?
    I think that Emba should create override method for TButton Font color or delete it

    ReplyDelete
  11. I don't see the logic: why do you put in IDE a propriety of an object if when you change it doesn't work?

    ReplyDelete
  12. Pacurariu Stelian It really is the point. If you run unthemed then these properties all have an impact. The properties existed long before XP themes, and are still meaningful in some circumstances. It's certainly surprising when you first encounter it, but Emba have got this right.

    ReplyDelete
  13. who on earth use OS before XP? :)) and I want to have an impact when running themed

    ReplyDelete
  14. Pacurariu Stelian The control existed before XP and it acquired these properties then. Were Emba to remove them then lots of existing code would break.

    What's more it is possible to run with themes disabled. For instance, Windows Classic mode. And then these properties have impact.

    Like I said, if you don't want the theme API to control your app's appearance, look to VCL styles or FMX.  Windows isn't going to change.

    ReplyDelete
  15. And if the only control you need this customisation for is a button, then a pure VCL control like TBitBtn would be the most expedient way to proceed.

    ReplyDelete
  16. I still don't use the silly XP themes on Windows 7. That whole track of development was a gigantic error, IMNSHO.

    ReplyDelete
  17. Christian Conrad I was like that too until I realised that my users were running with XP themes enabled and my Delphi 6 app looked dire in that scenario. It looked fine on my machine, but then I wasn't running with themes. Dog food was then consumed.

    ReplyDelete
  18. which one is simpler: change a color propriety, change a windows theme or edit a vcl style? why run an app unthemed?

    maybe a person who use an app doesn't know how to change a theme.

    if my app is installed on 10 computers then what? all the users must change the windows theme just to see a text color for a button?

    this sucks! better use TBitBtn. this component works on every OS and with every theme.

    ReplyDelete
  19. In your position, if you simply cannot use the themed button, and you only need to make a change on a button control, then TBitBtn or similar pure VCL control is the simplest change.

    ReplyDelete
  20. "Why run an app unthemed?" Because people are free to do whatever they like. And some people prefer not to have themes. Christian Conrad is such a person.

    Anyway, you seem angry.  It is what it is.  That's the decision that MS took.  It isn't going to change.  You understand it now, and know what your options are.

    ReplyDelete
  21. Pacurariu Stelian The historic architecture doesn't suddenly change because we no longer run XP. In fact, the Color property of the TButton existed in D1.

    ReplyDelete
  22. I am not angry :)) anyway using vcl style may cause issues with anchors

    ReplyDelete
  23. I like my apps to look like what the rest of the user's selected Windows theme looks like. If the user likes a dark theme, it would be silly if my app insisted on being bright white.

    ReplyDelete
  24. Pacurariu Stelian Yet in this entire thread you seem to take the opposite position what that espoused by Lars Fosdal

    ReplyDelete
  25. David Heffernan: I was talking as a user, not a developer. The whole point of a graphical user interface, as they were sold to the public back when they were new, was consistency between apps -- if everything looks and works the same, it's easier to learn the next app once you know a few of them.

    That would at first seem to preclude customisation, but fortunately at least Microsoft realised we could all have that cake and eat it too: By customising the interface as a whole, the user can customise his interface on his machine as he likes it, and still have perfect consistency between all his apps. Thank you, BillG, for Control Panel / Appearance!

    Then of course some bloody Kraut had to screw this up with his silly Power Tools, and before everyone was done oh-ing and ah-ing over those, even Microsoft themselves had forgotten their previous insight and started to ram weird non-standard interfaces down every Office user's throat, and then of course the rest of the world had to jump on the same bleeding stupid bandwagon... Sigh. :-(

    As a developer, sure, the sheeple of course expect the bling, conditioned as they are by all the stupid interface "bling" we've been inundated with ever since. In that role, I fortunately never had to care, since back when I was working with Delphi for a living I built in-house apps for people to do serious work with; they weren't being paid to Enjoy the Bling. So I never got around to investigating that whole Theme shtuff. Only, I always assumed apps could be built so that the user could turn the whole shebang off, and the app would revert to the standard Windows look? If not: That sucks, Borland.

    ReplyDelete
  26. Pacurariu Stelian: A button in my Windows on my computer should preferably look the way I want it to. By setting my preferences in Control Panel / Appearance (or WETF it's called nowadays), I, the user, tell the system what colour I want buttons to have
    on my machine. If you, the developer would like to respect the user's wishes, the buttons in your  app will automagically get the correct colour (i.e, according to my wishes) if you simply set their colour to clButtonFace.

    If, on the other hand, you don't want to respect the user's wishes, then just don't use clButtonFace or TButton -- use TBitBtn or some stupid TThemeButton or TBlingButton or whatever you want... But don't be too surprised if users don't flock to respect your wishes either.

    ReplyDelete
  27. Christian Conrad There's nothing sucking here at all. Developers build apps. Embarcadero don't build our apps for us. With the tools Embarcadero provide we can easily build apps that respect the users visual preferences. I don't know where you got the idea that the tools were deficient in that regard. They aren't.

    ReplyDelete
  28. You should see the DevExpress implementation of these things. There's skins and there's the old XP "native" style (4 of them) and there's win themed or unthemed on top (or in the bottom). Some properties are controlled by parent other by skinning engine or "styles". DX has kept a sleuth of different ways to control appearance for backwards compatibility and sometimes all these different "generations" of properties clash. Mostly one should be aware of what works and not. Then it's tempting to use their "styles" instead of owner drawing but that does not always work and as stated above may depend on the target machines windows version. It is especially annoying when you start out with their editor suite if you are a trial-and-error kind of coder :) Using "deprecated" would not work because some properties are not in some contexts. Oh, and styles can be overridden for individual controls, too. In different ways.

    ReplyDelete
  29. +Christian You should also avoid using offensive slang terms for people of a specific nationality. You might care to edit that part of the post.

    ReplyDelete
  30. Sorry if I was being unclear, David Heffernan,  or probably just too wordy: Try to wade through my last paragraph again and you'll see that I'm not saying BorlInCodEmp's implementation of Themey thingies does suck (which I never bothered to find out whether it did), only that it might suck (namely if the whole Themey-thingy shtuff isn't switcher-offable with some moderate effort on the developers part).

    ReplyDelete
  31. Somebody please tell +David Heffernan that I really wasn't trying to be mean to him (or even BorlEmcadero). I'm sorry if anything I wrote came off as an insult; I really can't see how it could be percieved that way, though. :-(

    It saddens me that just as I'd discovered his often insightful comments, he went and blocked me. Here's hoping he might reconsider some day.

    ReplyDelete
  32. So... Finaly if i want to make an application with TButton font text color green, that always look green independent of the win theme, which is the best solution? TBitbtn? :))

    ReplyDelete

Post a Comment