Re[3]: Помогите бедному ламеру поменять цвет фона
От: febus Германия  
Дата: 22.09.06 16:20
Оценка:
Здравствуйте, IRINIC, Вы писали:
SM>>Обработать сообщение WM_ERASEBKGND — в нем можно залить фон каким либо цветом, или даже вывести картинку.

IRI>Можно уточнить, каким образом?


Примерно вот так: (сам не проверял, но вроде бы ок. Украдено здесь)
BOOL CMYDialog::OnEraseBkgnd(CDC* pDC)
{
    // TODO: Add your message handler code here and/or call default

    CBitmap bmpBackground;
    VERIFY( bmpBackground.LoadBitmap( IDB_BITMAP1) );
    // Get the dimensions of the bitmap.
    BITMAP bm;
    bmpBackground.GetObject( sizeof(BITMAP), &bm );
    // How big is the destination window?
    RECT clientRect;
    GetClientRect( &clientRect );
    // Get the position to draw the upper
    // left corner of the bitmap.
    CPoint point( clientRect.left, clientRect.top );
    // Get the width and height the bitmap
    // needs to be drawn.
    CSize size( clientRect.right, clientRect.bottom );
    // Create a memory DC compatible with the window's DC.
    CDC memDC;
    VERIFY( memDC.CreateCompatibleDC( pDC ) );
    // Select the background bitmap into the memory DC.
    CBitmap* pOldBmp = memDC.SelectObject( &bmpBackground );
    ASSERT( pOldBmp != NULL );
    // StretchBlt the bitmap onto the window's background.
    pDC->StretchBlt( point.x, point.y, size.cx, size.cy,
    &memDC, 0, 0, bm.bmWidth-1, bm.bmHeight-1,
    SRCCOPY );
    // Select out the bitmap.
    VERIFY( memDC.SelectObject( pOldBmp ) );
    // Delete the bitmap that was loaded.
    bmpBackground.DeleteObject();
    return TRUE;
}
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.