Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > General Discussion
  New Posts New Posts RSS Feed - CWnd drawing background problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CWnd drawing background problem

 Post Reply Post Reply
Author
Message
BastianPL View Drop Down
Groupie
Groupie
Avatar

Joined: 15 April 2006
Status: Offline
Points: 69
Post Options Post Options   Thanks (0) Thanks(0)   Quote BastianPL Quote  Post ReplyReply Direct Link To This Post Topic: CWnd drawing background problem
    Posted: 24 April 2007 at 6:12am
Hi,

I am creating a CWnd object in CView class. I would like to change a
background colour of created window but my code doesn't work. Do you
have any ideas how to resolve my problem:

My code is:

CWnd *pWnd = &m_wndClient;

    UINT nClassStyle = CS_CLASSDC | CS_SAVEBITS | CS_HREDRAW |
CS_VREDRAW;

    BOOL bDropShadow;
    ::SystemParametersInfo( SPI_GETDROPSHADOW, 0, &bDropShadow, FALSE );
    if ( bDropShadow )
        nClassStyle |= CS_DROPSHADOW;

    CString szClassName = AfxRegisterWndClass( nClassStyle, 0, NULL, 0 );
    pWnd->CreateEx( 0, szClassName, "", WS_VISIBLE | WS_CHILD |
WS_BORDER, 200, 200, 400, 400, this->GetSafeHwnd(), 0, NULL );

    CDC *pDC = pWnd->GetDC();

    CBrush Brush;
    Brush.CreateStockObject( WHITE_BRUSH );
    CRect r( 200, 200, 400, 400 );
    CBrush *pOldBrush = pDC->SelectObject( &Brush );
    pDC->Rectangle( r );
    pDC->FillRect( &r, &Brush);
    pWnd->Invalidate();

    pDC->SelectObject( pOldBrush );
    Brush.DeleteObject();
Bastian
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 24 April 2007 at 7:24am
Hi,
Override this CWnd and fill background in its WM_PAINT handler.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
BastianPL View Drop Down
Groupie
Groupie
Avatar

Joined: 15 April 2006
Status: Offline
Points: 69
Post Options Post Options   Thanks (0) Thanks(0)   Quote BastianPL Quote  Post ReplyReply Direct Link To This Post Posted: 24 April 2007 at 1:23pm
I already done this.
 
Thanks
Bastian
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.