Print Page | Close Window

CWnd drawing background problem

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: General Discussion
Forum Description: Topics Related to Visual C++ MFC Development in General
URL: http://forum.codejock.com/forum_posts.asp?TID=6963
Printed Date: 18 May 2024 at 2:20pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CWnd drawing background problem
Posted By: BastianPL
Subject: CWnd drawing background problem
Date 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



Replies:
Posted By: Oleg
Date 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


Posted By: BastianPL
Date Posted: 24 April 2007 at 1:23pm
I already done this.
 
Thanks


-------------
Bastian



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net