Results 1 to 17 of 17

Thread: VB6 + Command Buttons = Strange Behavior?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208

    Question

    I have some command buttons on my form. I'd like their backcolor to be purple.

    I found that I had to set the style property to 1 (Graphical) in order to see the backcolor.

    But now, when style =1 I'm getting strange behavior . . .the buttons partially disappear, and a grey "ghost" of the button appears in the background?

    Has anyone else seen this? I've tried setting autoredraw = true, but that didn't do anything.

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Elizabeth,

    You might want to look at adding the Microsoft Forms 2.0 Object Library to your project. It allows you to change the backColor and foreColor of command buttons. It has it's quirks, like you cannot key in a shortCut for the button. E&xit in the caption shows E&xit instead of underlining the "x" like the standard command button.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    Bart . . .

    Hm, that's no good . . . I need the underline, too.

    Why on earth can't I change the backcolor of a command button like VB5?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    FROM MICROSOFT

    FIX: Standard Style CommandButton Displays a BackColor

    --------------------------------------------------------------------------------
    The information in this article applies to:

    Microsoft Windows CE Toolkit for Visual Basic 5.0, version 1.0

    --------------------------------------------------------------------------------


    SYMPTOMS
    A CommandButton with its Style property set to "0 - Standard" and its BackColor property set to a color (other than gray) displays the Backcolor at run-time. This behavior should not occur unless the Style property is set to "1 - Graphical."



    STATUS
    Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

    This problem was corrected in Windows CE Toolkit for Visual Basic 6.0.




    MORE INFORMATION

    Steps to Reproduce Behavior
    Start a new Windows CE Project in Visual Basic 5.0. Form1 is created by default.


    Place a CommandButton on Form1.


    Set the BackColor property of the CommandButton to a color, such as red. Make sure the Style property of the CommandButton is set to "0 - Standard," which is the default.


    Press the F5 key to run the project, and note that the button is red. This behavior should only occur when the Style property of the button is set to "1 - Graphical."

    NOTE: This behavior also occurs if you set the BackColor property in code at run-time.

    -----------------------------------------------------------------------

    What?!@?@? That's not a bug, that's the way it should work. Why must the style be graphical in order to see a backcolor???? If I want a textbox backcolor to be red, I don't have to change any style property.

    That my command buttons disappear and are replaced with ghostlike grey boxes, THAT'S a bug!!!!!!!!!!!!!!!

  5. #5

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    I tried to do a screen shot of the problem, and I'm attaching it to this post. Hope it works.

    I have a form (Query) which loads another form (Codes).

    When I go to Unload Codes, I also unload Query. Then I reload Query.

    Codes is used to update the data in Query. So I unload and reload so the changes that the user has made are reflected in Query.

    You're seeing the buttons on Query. The top button is now transparent, and you can see the window behind it.

    Whatever button I click on, that's the one that becomes transparent. So if I click on "Copy," then you'd see this same problem only with Copy.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    Hmm, I don't see my attachment; I'll try again.
    Attached Images Attached Images  

  8. #8

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    *sigh* Yup.

    Now I have a new problem . . . my code works when I run it in VB. Then I make an .exe and poof! It just disappears when I hit the command button.

    *sigh*

    Nope, I didn't change any other properties, except backcolor.

  10. #10

  11. #11
    Hyperactive Member
    Join Date
    Mar 2001
    Posts
    485
    Originally posted by Elizabeth
    Hmm, I don't see my attachment; I'll try again.
    How about the other 2 buttons, do they disappear when you click on them?

    It works fine on my PC though, with background color changed.

    Maybe your display card has some incompatibility?

    Harddisk

  12. #12
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    I have tried this with multiple buttons with the background set to different colors, and with multiple forms. Everything appears to be working fine. The buttons always display correctly.

    Are you running any long complex routines when the buttons are clicked? Perhaps the screen is not getting a chance to be refreshed.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    Well, the .exe problem seems to have mysteriously vanished . . . which is good news.

    Bart -- I'm dynamically loading a bunch of controls, if that's long and complex . . .

    Should I just try sticking the "Refresh" command in there somewhere?

    Martin -- the only thing I can think of is that a lot of this code was written with VB5, but we recently upgraded to VB6.

    I could try the code on another machine and see if that makes any difference.

  14. #14
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    If you have a long routine, you might put a DoEvents in there so the screen will have a chance to redraw.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    *sigh* I've thrown me.refresh and DoEvents in a bunch of places, but it doesn't seem to make any difference.

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    Anybody??????????

  17. #17
    Junior Member traze's Avatar
    Join Date
    Mar 2001
    Location
    Bradenton FL, USA
    Posts
    30

    Cool hmmmmm,

    You could always switch back to gray buttons instead of barney buttons... j/k....
    DMS
    ---"tip of the red hat to ya"

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