I'm using the code below to try and change teh color of an SDI I am using to
help me learn at the moment. It changes teh background to the color I want
but soon as I type the lines typed are in white.

Now I've got to admit I'm way over my depth here, but it is driving me a bit
nuts trying to work this out. (Maybe I should have waited a bit longer)

If this is the wrong group please direct me to a one more suited.

Thanks in advance....



Wayne...

CODE:
--------



BOOL Cnotepad_testView::OnEraseBkgnd(CDC* pDC)

{

CBrush brNew(RGB(255,255,204)); //Creates a blue brush

CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brNew);

CRect rc;

pDC->GetClipBox(rc); // Gets the co-ordinates of the client

// area to repaint.

pDC->PatBlt(rc.left,rc.top,rc.Width(),rc.Height(),PATCOPY);

//pDC->PatBlt(0,0,rc.Width(),rc.Height(),PATCOPY);

// Repaints client area with current brush.

pDC->SelectObject(pOldBrush);

return TRUE; // Prevents the execution of return

// CView::OnEraseBkgnd(pDC) statement

}

Re: Change background colour in SDI by Scott

Scott
Fri Oct 01 07:43:45 CDT 2004

Wayne... wrote:

> I'm using the code below to try and change teh color of an SDI I am using to
> help me learn at the moment. It changes teh background to the color I want
> but soon as I type the lines typed are in white.
>
> Now I've got to admit I'm way over my depth here, but it is driving me a bit
> nuts trying to work this out. (Maybe I should have waited a bit longer)
>
> If this is the wrong group please direct me to a one more suited.
>
> Thanks in advance....
>
>
>
> Wayne...

You didn't show how you are displaying the text. If you are using
pDC->DrawText or a similar function to draw the text, you want to call
pDC->SetBkMode(TRANSPARENT) before drawing the text.

--
Scott McPhillips [VC++ MVP]


Re: Change background colour in SDI by Jeff

Jeff
Fri Oct 01 06:46:09 CDT 2004

Is this a CEditView derived view? If so, you will probably have better
results handling the reflected (=WM_CTLCOLOR) message and leaving
WM_ERASEBKGND alone.
--
Jeff Partch [VC++ MVP]


"Wayne..." <w.robson@oneteldsl.net> wrote in message
news:415d3b85@212.67.96.135...
> I'm using the code below to try and change teh color of an SDI I am using
to
> help me learn at the moment. It changes teh background to the color I
want
> but soon as I type the lines typed are in white.
>
> Now I've got to admit I'm way over my depth here, but it is driving me a
bit
> nuts trying to work this out. (Maybe I should have waited a bit longer)
>
> If this is the wrong group please direct me to a one more suited.
>
> Thanks in advance....
>
>
>
> Wayne...
>
> CODE:
> --------
>
>
>
> BOOL Cnotepad_testView::OnEraseBkgnd(CDC* pDC)
>
> {
>
> CBrush brNew(RGB(255,255,204)); //Creates a blue brush
>
> CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brNew);
>
> CRect rc;
>
> pDC->GetClipBox(rc); // Gets the co-ordinates of the client
>
> // area to repaint.
>
> pDC->PatBlt(rc.left,rc.top,rc.Width(),rc.Height(),PATCOPY);
>
> //pDC->PatBlt(0,0,rc.Width(),rc.Height(),PATCOPY);
>
> // Repaints client area with current brush.
>
> pDC->SelectObject(pOldBrush);
>
> return TRUE; // Prevents the execution of return
>
> // CView::OnEraseBkgnd(pDC) statement
>
> }
>
>
>
>
>



Re: Change background colour in SDI by GuitarBill

GuitarBill
Fri Oct 01 15:12:44 CDT 2004

If you're just painting a solid color, you can do it thus:

CRect rect;
GetClientRect(&rect);
pDC->FillSolidRect(&rect, RGB(r, g, b));

And use pDC->SetBkMode(TRANSPARENT) before drawing your text.


"Wayne..." <w.robson@oneteldsl.net> wrote in message
news:415d3b85@212.67.96.135...
> I'm using the code below to try and change teh color of an SDI I am using
to
> help me learn at the moment. It changes teh background to the color I
want
> but soon as I type the lines typed are in white.
>
> Now I've got to admit I'm way over my depth here, but it is driving me a
bit
> nuts trying to work this out. (Maybe I should have waited a bit longer)
>
> If this is the wrong group please direct me to a one more suited.
>
> Thanks in advance....
>
>
>
> Wayne...
>
> CODE:
> --------
>
>
>
> BOOL Cnotepad_testView::OnEraseBkgnd(CDC* pDC)
>
> {
>
> CBrush brNew(RGB(255,255,204)); //Creates a blue brush
>
> CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brNew);
>
> CRect rc;
>
> pDC->GetClipBox(rc); // Gets the co-ordinates of the client
>
> // area to repaint.
>
> pDC->PatBlt(rc.left,rc.top,rc.Width(),rc.Height(),PATCOPY);
>
> //pDC->PatBlt(0,0,rc.Width(),rc.Height(),PATCOPY);
>
> // Repaints client area with current brush.
>
> pDC->SelectObject(pOldBrush);
>
> return TRUE; // Prevents the execution of return
>
> // CView::OnEraseBkgnd(pDC) statement
>
> }
>
>
>
>
>