Здравствуйте, ffk, Вы писали:
ffk>Возникла такая проблема:
ffk>Создаю диалог через DialogBoxParam, на этапе WM_INIT.. перемещаю некоторые контролы в зависимости от разрешения экрана,
ffk>подгружаю BMPшку и устанавливаю ее HBITMAP в один из picture controlов, после чего ее тоже резайзю. В итоге имею то что
Касательно фона — не есть правильный метод.
ffk>1) Tab order изменился, все контролы пробегаются в обратном порядке (всего их 3)
Тут я тебе не подскажу, бо не знаю!
ffk>2) Т.к. картинка растягивается на весь эран она перекрывает все контролы. Как сделать так чтоб она была задним фоном.
Мне кажется, правельнее будет рисовать твой битмап сразу на контекст всего диалога и тогда не будет проблем с отображением контролов! А ресайз тоже не проблема, выводишь картинку через StretchBlt.
Вот ф-я которая это делает:
// This routine draws a bitmap to a context. We use this function to draw
// main window and dialog background
HRESULT DrawBitmapToContext( HWND hWnd, UINT nBitmapID )
{
HRESULT hr = E_FAIL;
RECT r = { 0, 0, 0, 0 };
RECT rBmp = { 0, 0, 0, 0 };
HBITMAP hBitmap = NULL;
try {
// hWnd == NULL is allowed as we want to draw on the entire screen
if ( nBitmapID == 0 ) throw L"Invalid arguments";
// Load bitmap from resource
hBitmap = LoadBitmap( hAppInstance/*GetModuleHandle( NULL )*/, MAKEINTRESOURCE( nBitmapID ) );
// Get destanation DC, to where we will paint
HDC hdcScreen = GetDC( hWnd );
if ( hWnd == NULL )
{
r.right = GetDeviceCaps( hdcScreen, HORZRES );
r.bottom = GetDeviceCaps( hdcScreen, VERTRES );
}
else
GetClientRect( hWnd, &r );
// We should find out the size of the bitmap
BITMAP bm;
INT result = GetObject( hBitmap, sizeof( BITMAP ), &bm );
rBmp.right = bm.bmWidth;// == 0 ? GetDeviceCaps( hdcScreen, HORZRES ) : bm.bmWidth;
rBmp.bottom = bm.bmHeight;// == 0 ? GetDeviceCaps( hdcScreen, VERTRES ) : bm.bmHeight;
// Create memory DC compatible with destanation hdcScreen
HDC hdcMem = CreateCompatibleDC( hdcScreen );
// Select Bitmap on memory DC
HGDIOBJ hObject = SelectObject ( hdcMem, hBitmap );
// Maps pixels from the source rectangle into blocks of pixels in the destination rectangle.
// The average color over the destination block of pixels approximates the color of the source pixels
BOOL res = SetStretchBltMode( hdcScreen, HALFTONE );
// Copy memory DC with bitmap into destanation DC
res = StretchBlt( hdcScreen, 0, 0, r.right, r.bottom, hdcMem, 0, 0, rBmp.right, rBmp.bottom, SRCCOPY );
// Select old GDI object to memory DC
SelectObject ( hdcMem, hObject );
// Release destanation DC
::ReleaseDC( NULL, hdcScreen );
// Delete loaded bitmap
DeleteObject( hBitmap );
hr = S_OK;
}
catch ( ... )
{
};
return hr;
};
Удачи!
... << RSDN@Home 1.1.3 beta 1 >>