Results 1 to 7 of 7

Thread: Changing Button Background and Text Colours

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Unhappy

    A hardish one for you GDI people.

    I'm trying to change the text colour and background colour of a Button using API (I have reasons).

    I managed to change the text colour using BS_OWNERDRAW and SetTextColour. I also changed the colour of the box using
    CreateSolidBrush and FillRect however this leaves me with 2 problems:

    1). The Rect is now flat - the button no longer looks like a button.

    2). The text is invisible (the FillRect has filled over my Text!)

    Does anyone know how to change the background colour of a button while keeping it looking like an button AND keeping the text visible (like changing the system colour - but obviously not changing the system colours!!!)

    I need this pretty quick - so if anyone has the answer I'd be eternally grateful!

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Unhappy

    OK...if I do the background first...the text stays visible, but I've still lost the 3d effect.

    Do I have to ownerdraw it?

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You use Fillrect right? Then you could just make the rect smaller by 1 pixel at each border
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Lightbulb Kinda Works

    Kedaman,

    That sort of works but it draws the rect at client 0,0 (i.e. the top corner of the button). How can I adjust the DC to draw it at client (1,1) (Or whatever?)

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Talking

    Its ok...I figured it out.

    Its in client coords so add to top and left, and minus from bottom and right.

    Do you know any way to adjust a colour value?

    A standard button is medium grey yes? and a pixel on the top and left is white, a pixel on the botom and right is dark grey.

    To complete the effect of what I'm doing, if I change the button colour to (Say) red, can I calculate a light red (red+white) for the top/left and a dark red (red+dark grey) for the bottom/right?

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    yep, you could change the color light by multiplying each colorcomponent by a constant

    Well not sure how you change the color, but you could use setpixel, a slightly slower than lineto, on the other hand you could blit i line you've drawn on a DC earlier
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2000
    Location
    Sedgefield
    Posts
    337

    Talking

    Got that too.

    To lighten: (R+255)/2,(G+255)/2,(B+255)/2
    To darken: (R)/2,(G)/2,(B)/2

    Dan

    Outside of a dog, a book is a man's best friend.
    Inside of a dog, it's too dark to read.

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