Click to See Complete Forum and Search --> : Can't draw in DIB


Linslv77
December 1st, 2003, 08:30 PM
below is my code:
-------------------------------------------------
HDC hDC;
HFONT hFont;
RECT rect;
DWORD* pBitmapBits;
BITMAPINFO bmi;
HBITMAP hbmBitmap = NULL;

hDC = CreateCompatibleDC( NULL );
SetMapMode( hDC, MM_TEXT );
ZeroMemory( &bmi.bmiHeader, sizeof(BITMAPINFOHEADER) );
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = (int)100;
bmi.bmiHeader.biHeight = (int)100;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biBitCount = 32;

hFont = CreateFont( 0, 0, 0, 0, FW_BOLD, FALSE,
FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,VARIABLE_PITCH, _T("Arial"));
SelectObject( hDC, hFont );

hbmBitmap = CreateDIBSection( hDC, &bmi, DIB_RGB_COLORS,
(void**)&pBitmapBits, NULL, 0 );
SelectObject( hDC, hbmBitmap );
SetTextColor(hDC, RGB(100,100,100));
SetBkColor( hDC, RGB(255,255,255));
SetBkMode(hDC, OPAQUE);
SetTextAlign( hDC, TA_TOP );
ExtTextOut(hDC, 0, 0, 0, NULL, str, strlen(str), NULL);
-------------------------------------------------
then I watch memory at the pointer pBitmapBits.It is still all 0x00.
I had check return value of each function.and it's all OK.
where's the problem??