Announcement

Collapse
No announcement yet.

hbrBackground

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    hbrBackground

    Today, I'm not the sharpest tool in the shed, ...I cannot recall why +1 is required
    ...this +1 automatically converts it to an HBRUSH ???

    Code:
    hbrBackground
    
    Identifies the class background brush. This member can be a handle to the physical brush to be 
    used for painting the background, or it can be a color value. A color value must be one of the 
    following standard system colors (the value 1 must be added to the chosen color). If a color value is 
    given, you must convert it to one of the following HBRUSH types: 
    
    COLOR_ACTIVEBORDER
    COLOR_ACTIVECAPTION
    COLOR_APPWORKSPACE
    COLOR_BACKGROUND
    COLOR_BTNFACE
    COLOR_BTNSHADOW
    COLOR_BTNTEXT
    COLOR_CAPTIONTEXT
    COLOR_GRAYTEXT
    COLOR_HIGHLIGHT
    COLOR_HIGHLIGHTTEXT
    COLOR_INACTIVEBORDER
    COLOR_INACTIVECAPTION
    COLOR_MENU
    COLOR_MENUTEXT
    COLOR_SCROLLBAR
    COLOR_WINDOW
    COLOR_WINDOWFRAME
    COLOR_WINDOWTEXT

    #2
    Jules,

    Basically using "0" tells Windows to not paint the background, but since the color constants also cover 0 you need to +1 to other values (you use a COLOR_ value).

    The background can be a brush handle, color constant+1 (what they call a "HBRUSH type" above), or 0 if you draw it yourself.
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


      #3
      Thanks Kev,

      So if to use %COLOR_SCROLLBAR = 0 , then +1 to assure its not a %NULL brush.
      I recall if I use a %NULL Brush, I paint myself or supply my own created brush.

      but if I use %COLOR_BTNFACE = 15 or any other non-zero constant...

      i.e. twcx.hbrBackground = %COLOR_BTNFACE gives me the wrong color?

      and

      twcx.hbrBackground = %COLOR_BTNFACE+1 gives to me the correct color.

      sorry, I'm still a little fuzzy.

      -----
      OK... only logic I can find...
      There's a set of color constants for various parts of Windows interface.
      Those constants start at zero (ie. %COLOR_SCROLLBAR has numeric value 0),
      and so you have to add one to the constant when using it in place of
      hBrush in WndClassEx: otherwise, %COLOR_SCROLLBAR would be
      indistinguishable from %NULL handle.
      Guess one could use GetSysColorBrush(%COLOR_xxxx) to avoid the +1 logic.
      Now I understand more ways to skin a carrot...
      Last edited by Jules Marchildon; 1 Jul 2009, 10:49 AM. Reason: added comments...

      Comment


        #4
        Jules,

        You have three choices:

        1. hbrBackground = %NULL (no background)
        2. hbrBackground = %COLOR_XXX + 1 (color value, ALWAYS add 1)
        3. hbrBackground = hBrush (use specified brush)

        Hope that's clearer
        kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎