Results 1 to 9 of 9

Thread: Command Button (API) change BackColor with Style = 0 - Standard

  1. #1

    Thread Starter
    Addicted Member Davor Geci's Avatar
    Join Date
    Sep 2009
    Posts
    222

    Command Button (API) change BackColor with Style = 0 - Standard

    Hello friends,

    I sure that this is answered already in this forum (somewhere), but can't find it (So sorry for duplication).

    Do you know the code (API-s) how to change the Command Button backcolor property, but with Style = 0 - Standard (I want to use the manifest for theming)

    Davor
    My projects:
    Virtual Forms
    VBA Telemetry

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Command Button (API) change BackColor with Style = 0 - Standard

    This might get you there.

    Elroy

    EDIT1: Also, I'm not positive, but Krool's work over in the codebank might also get you there. I'd start by examining his CommandButtonW control.

    EDIT2: I played around with the latest version of Krool's controls, and he doesn't seem to have a working BackColor for his command button. So, this might still be an open question.
    Last edited by Elroy; Jan 11th, 2017 at 01:29 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Command Button (API) change BackColor with Style = 0 - Standard

    I suspect the only answer is to owner-draw the control, which can be quite a pain. Doubly so if you want to be consistent with the UxTheme, which varies by Windows version and likely depends on user settings that can revert to a non-themed GUI using funky colors, font faces and sizes, etc.

    So with some work you might get it to sort of do what you want but then on another machine it may look hilariously out of place with everything else.


    If you insist on a skinned UI you might want to just abandon most of VB and slop in some HTML rendering control or 3rd party widget library. At that point you may as well be writing in C or some other "dark world" language.

  4. #4
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Command Button (API) change BackColor with Style = 0 - Standard

    Davor - You may know this already...In a non themed button its Backcolor Property has no affect in standard mode. In a themed button however if you set the Backcolor you can have buttons which look like this;
    Name:  Capture.PNG
Views: 314
Size:  3.5 KB

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Command Button (API) change BackColor with Style = 0 - Standard

    Good point, that might be an option.

    It relies on a quirk of the stock UxTheme in some versions of Windows, and if a user has a custom theme set for Accessibility or just contrariness those colors may not appear. However they seem to hang in there in a similar form in Windows 10 High-Contrast Mode though. At least Windows 10 1607, I can't tell about earlier updates.

    Turn high contrast mode on or off in Windows


    Name:  sshot.png
Views: 241
Size:  1.5 KB
    Last edited by dilettante; Jan 12th, 2017 at 07:49 AM.

  6. #6
    Frenzied Member
    Join Date
    Apr 2012
    Posts
    1,253

    Re: Command Button (API) change BackColor with Style = 0 - Standard

    Wow, dil, you managed to make Windows 10 even uglier than it is out of the box. No mean feat!
    If you don't know where you're going, any road will take you there...

    My VB6 love-children: Vee-Hive and Vee-Launcher

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Command Button (API) change BackColor with Style = 0 - Standard

    Well after you use Windows 10 for a while you go blind, then you need high-contrast mode.

  8. #8

    Thread Starter
    Addicted Member Davor Geci's Avatar
    Join Date
    Sep 2009
    Posts
    222

    Re: Command Button (API) change BackColor with Style = 0 - Standard

    These are very interesting info guys.

    Didn't know that. (Didn't try before)
    My projects:
    Virtual Forms
    VBA Telemetry

  9. #9
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Command Button (API) change BackColor with Style = 0 - Standard

    A side issue but related - Worth remembering (more so under vista and Win7) when Form.BackColor is not equal to the default CommandButton.BackColor the appearance of themed buttons is improved if the CommandButton.BackColor is set to match the Form.BackColor. As per the right hand button in this example.

    Name:  Capture.JPG
Views: 290
Size:  14.3 KB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width