CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    79

    Change backgroung?

    Hello:
    I build a bitmap the code:
    int ControlView::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if (CScrollView::OnCreate(lpCreateStruct) == -1)
    return -1;
    CClientDC dc(this);
    CBitmap bit;
    CDC memdc;
    m_nMaxX=GetSystemMetrics(SM_CXSCREEN);
    m_nMaxY=GetSystemMetrics(SM_CYSCREEN);
    memdc.CreateCompatibleDC(&dc);
    bit.CreateCompatibleBitmap(&dc,m_nMaxX,m_nMaxY);
    CBitmap* pOldBitmap=memdc.SelectObject(&bit);
    m_hBrush=(HBRUSH)memdc.SelectStockObject(BLACK_BRUSH);
    memdc.SelectObject(m_hBrush);
    memdc.PatBlt(0,0,m_nMaxX,m_nMaxY,PATCOPY);

    }
    I want use BLACK_BRUSH brush background.But it's not work.
    Why?Who can tell me?
    THank you!


  2. #2
    Guest

    Re: Change backgroung?

    Try add windows message handler WM_CTLCOLOR


  3. #3
    Guest

    Re: Change backgroung?

    To change your background brush, put the following code
    in your view classes precreatewindow method.


    BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: Modify the Window class or styles here by modifying
    // the CREATESTRUCT cs
    if( !CScrollView::PreCreateWindow(cs) )
    {
    return FALSE;
    }

    cs.lpszClass = AfxRegisterWndClass( CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW, 0, ::CreateSolidBrush(RGB(0,0,0)) );
    if( cs.lpszClass != NULL )
    {
    return TRUE;
    }
    else
    {
    return FALSE;
    }
    }



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured