locked
how to color a dialog RRS feed

  • Question

  • HDC hdc = BeginPaint(hwnd, &ps);
    COLORREF origRef = SetBkColor(hdc, RGB(128, 128, 128));
    if (CLR_INVALID == origRef)
        origRef = origRef;
    
    EndPaint(hwnd, &ps);
    Hello,
    I've been trying to implement a small test dialog (PPC 5) which paints itself with different colors (not using MFC)
    and i've already tried to use the examples such as: http://www.pocketpcdn.com/forum/viewtopic.php?t=9726&view=next&sid=1fb9e3314ce9428c4aebe32d5f2bac91
    Does anyone have a good example for such issue?
    What i tried to do is simply override the WM_PAINT event and do the following:
    HDC hdc = BeginPaint(hwnd, &ps);
    COLORREF origRef = SetBkColor(hdc, RGB(128, 128, 128));
    if (CLR_INVALID == origRef)
    origRef = origRef;
    
    			EndPaint(hwnd, &ps);
    Thursday, August 6, 2009 3:26 PM

Answers

  • Hi robybd,

    You can handle WM_CTLCOLOR to paint dialog.
    Create a color brush of any type like CreateSolidBrush().
    Fill the window rect using brush created using FillRect().

    Try it, let me know if it works.

    Best Regards,
    Pariksheet.
    • Marked as answer by robybd Sunday, August 9, 2009 6:26 AM
    Friday, August 7, 2009 5:43 AM

All replies

  • You've set the background color for rendering operations but you never actually rendered.  That's like selecting a colored pencil for drawing but not actually drawing.   You need to perform a drawing operation between BeginPain() and EndPaint();
    Joel Ivory Johnson
    Friday, August 7, 2009 3:46 AM
  • Hi robybd,

    You can handle WM_CTLCOLOR to paint dialog.
    Create a color brush of any type like CreateSolidBrush().
    Fill the window rect using brush created using FillRect().

    Try it, let me know if it works.

    Best Regards,
    Pariksheet.
    • Marked as answer by robybd Sunday, August 9, 2009 6:26 AM
    Friday, August 7, 2009 5:43 AM
  • Hi,

    I tried the solution you suggested and it worked but i had to do a small change, instead of using the painting in WM_CTLCOLOR event
    i did it in the WM_PAINT event, thanks.
    Sunday, August 9, 2009 6:26 AM