Cannot draw on wxMemoryDC using colour 0xc0c0c0

Leslie Newell lesnewell at fmail.co.uk
Mon Feb 4 07:48:26 PST 2008


Hi, I have just hit a really strange problem with wxMemoryDC. I am 
trying to draw a simple rectangle on a wxBitmap using wxMemoryDC. It 
works fine if I use any colour other than 0xc0c0c0. For instance 
0xc1c1c1, 0xbfbfbf or 0xc0c0c1 work with no problems. Below is the code 
I am using:

    size_t nCheckWidth  = wxOwnerDrawn::GetDefaultMarginWidth(),
           nCheckHeight = wxOwnerDrawn::GetDefaultMarginWidth();
    wxBitmap bmp(nCheckWidth + 1,nCheckHeight +1);
    wxMemoryDC dc(bmp);
    wxColour bkCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
    wxBrush bkBrush(bkCol);
    dc.SetBackground(bkBrush);
    dc.Clear();
    dc.SetBrush(*wxTRANSPARENT_BRUSH);
    dc.SetPen(wxPen(wxColour(0xc0,0xc0,0xc0)));
    dc.DrawRectangle(1,1, nCheckWidth-2, nCheckHeight-2);
    return(bmp);

wxWidgets 2.8.6, MSW, compiled with msvc (Visual Studio 2005)

Les




More information about the wx-users mailing list