1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
PAINTSTRUCT ps;
hdc = BeginPaint(hWnd, &ps);
if(!hdc){
MessageBox(NULL,TEXT("Error painting!"),TEXT("Error"),MB_OK);
break;
}
hdcMem = CreateCompatibleDC( hdc );
if(!hdcMem){
MessageBox(NULL,TEXT("Error creating compatible DC!"),TEXT("Error"),MB_OK);
break;
}
if(!OpenClipboard(NULL)){
MessageBox(NULL,TEXT("Unable to access clipborad!"),TEXT("Error"),MB_OK);
break;
}
hndl = GetClipboardData(CF_BITMAP);
CloseClipboard();
if(!hndl){
MessageBox(NULL,TEXT("Unable to read from clipboard!"),TEXT("Error"),MB_OK);
TCHAR str[255];
_stprintf(str, _T("Error code:%d"), GetLastError());
MessageBox(0, str, TEXT("ERROR CODE!"), MB_OK);
//MessageBox(NULL,(LPCTSTR)GetLastError(),TEXT("Error code!"),MB_OK);
break;
}
cbmp = (HBITMAP)hndl;
if(!cbmp){
MessageBox(NULL,TEXT("Unable to read image from the clipboard!"),TEXT("Error"),MB_OK);
break;
}
SelectObject(hdcMem,cbmp);
GetObject(hndl,sizeof(bmp),&bmp);
BitBlt(hdc,0,0,bmp.bmWidth,bmp.bmHeight,hdcMem,0,0,SRCCOPY);
DeleteDC(hdcMem);
EndPaint(hWnd, &ps);
break;
|