Menu

Static background problems...

2003-02-02
2012-09-26
  • Nobody/Anonymous

    I've wasted most of the weekend on this, so I decided to consult you guys once more..

    Here's the problem:
    In a window I have a text in a static control. Like this:

    HWND hLabel = CreateWindowEx (0, TEXT("STATIC"),
    TEXT("some label"), WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, // x,y,w and h are set in WM_SIZE
    hwnd, (HMENU)IDLABEL1, ghInst, NULL);

    This label has a gray background, no matter what the current background is. So I decided I should perhaps set it to transparent and included this in my windproc:

    case WM_CTLCOLORSTATIC:
    {
       if (LOWORD(wParam) == IDLABEL1)
       {
           SetBkMode((HDC)wParam,TRANSPARENT);
       }
       return FALSE;
    }

    ..and the backgound turns white. Nothing works. I tried these:

    SetTextColor((HDC)wParam,RGB(255,255,0));
    SetBkColor((HDC)wParam,RGB(0,0,255));

    The result is the same every time: only a white background. Even when I put nothing in the if statement. And without the 'return FALSE' I get a memory error.

    I'm probably making a very stupid and obvious mistake here. But what mistake?

    -Jay

     
    • Nobody/Anonymous

      Hi jay,

      First of all WM_CTLCOLORSTATIC must ALWAYS return a predefined HBRUSH (as the default background color). A second problem is in (LOWORD(wParam) == IDLABEL1) . This works fine in other messages, but not here since the HDC is in the wParam. To get the ID use: (GetDlgCtrlID((HWND)lParam) == IDLABEL1)

      -Jay

       
    • Nobody/Anonymous

      Jay,

      Go get some fresh air. You're talking to yourself.

      -Jay

       
    • Nobody/Anonymous

      Good idea.

      -Jay

       
    • Curtis Sutter

      Curtis Sutter - 2003-02-03

      lol, are you really the same guy, or two with the same name?  I vote for mutiple personalities.  Call Wayne he has a PhD, maybe he can fix you...

      Curtis

       
    • Nobody/Anonymous

      I think I am the same guy. I was when I just looked in the mirror.
      As for calling Wayne.. I am a PhD as well and therefore beyond salvation.

      -Jay

       
    • Curtis Sutter

      Curtis Sutter - 2003-02-04

      lol

      Curtis

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.