ok i have this procedure that will get a bitmap from the clipboard and display it in this child MDI window but the image will not show up until i move the window off the screen or if i resize it, does anyone see any flaws in this code. I am using Visual C++ 6 and Windows API on a windows XP box.
PHP Code:
LRESULT CALLBACK ClipProc( HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam )
{
HDC hdc;
HDC memhdc;
PAINTSTRUCT ps;
HWND hGetClip;
RECT rect;
BITMAP bm;
static HBITMAP hBitmap ;
HBITMAP hBitmapClip;
switch(Msg)
{
case WM_CREATE:
{
hGetClip = CreateWindowEx(0,"BUTTON","Get Image",WS_CHILD | WS_VISIBLE,
0,0,100,20,hWnd,(HMENU)HBUTTGETCLIP,NULL, 0);
break;
}
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case HBUTTGETCLIP:
{
if (hBitmap)
{
DeleteObject (hBitmap) ;
hBitmap = NULL ;
}
OpenClipboard (copyhwnd);
hBitmapClip = (HBITMAP)GetClipboardData (CF_BITMAP) ;
if (hBitmapClip)
{
hBitmap = CopyBitmap (hBitmapClip) ;
}
CloseClipboard () ;
break;
}
default:
{
break;
}
}
break;
}
case WM_PAINT:
{
hdc = BeginPaint(hWnd,&ps);
if (hBitmap)
{
GetClientRect (hWnd, &rect) ;
memhdc = CreateCompatibleDC (hdc) ;
SelectObject (memhdc, hBitmap) ;
GetObject (hBitmap, sizeof (BITMAP), (PSTR) &bm);
SetStretchBltMode (hdc, COLORONCOLOR) ;
StretchBlt (hdc, 0, 0, rect.right, rect.bottom,
memhdc, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY) ;
DeleteDC (memhdc) ;
}
EndPaint(copyhwnd,&ps);
break;
}
default:
{
break;
}
}
return DefMDIChildProc(hWnd, Msg, wParam, lParam);
}