CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    31

    [RESOLVED] Combobox/static color

    I've colored my window :RGB(195,217,250)
    Code:
    //Register the window class
    	wc.cbSize = sizeof(WNDCLASSEX);
    	wc.style = 0;
    	wc.lpfnWndProc = WndProc;
    	wc.cbClsExtra=0;
    	wc.cbWndExtra=0;
    	wc.hInstance=hInst;
    	wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    	wc.hCursor = LoadCursor(NULL,IDC_ARROW);
    	wc.hbrBackground=CreateSolidBrush(RGB(195,217,250));//(HBRUSH)(COLOR_WINDOW);
    	wc.lpszMenuName=NULL;
    	wc.lpszClassName=g_szClassName;
    	wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
    And I have created a static and a checkbox in my WM_CREATE but they come out that there is a grey rectangle arround the text I was wondering how to color it the same as the solidbrush of the window, I've tried doing SetBkColor(GetDc(..),[color]) but it doesn't work. Please help.
    Code:
    //create seach label
    	hwndlblSearch = CreateWindowEx(0,TEXT("static"),TEXT("Table/View name"),SS_LEFT|WS_CHILD|WS_VISIBLE,33,10,116,17,hwnd,(HMENU)lblSearch,NULL,NULL);
    
    //Checkbox Table
    	hwndcbTable = CreateWindowEx(0,TEXT("BUTTON"),TEXT("Table"),BS_AUTOCHECKBOX|WS_VISIBLE|WS_CHILD,265,32,100,25,hwnd,(HMENU)cbTable,NULL,NULL);
    Last edited by james2432; July 10th, 2009 at 06:19 AM.

  2. #2
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: Combobox/static color

    One way is to handle WM_CTLCOLORSTATIC and in the handler do something like:
    Code:
    case WM_CTLCOLORSTATIC:
            SetBkMode((HDC)wParam, TRANSPARENT);
            return GetStockObject(NULL_BRUSH);
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  3. #3
    Join Date
    Jun 2009
    Posts
    31

    Re: Combobox/static color

    Yeah I forgot to change this to solved

    WM_CTLCOLORSTATIC works for checkbox(text), groupbox,static text(label) instead of returning a (NULL_BRUSH) i returned a HBRUSH of the same color

    I also did a SetBkMode to transparent

    thanks

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

Featured