Hello everyone,
I have been driving myself crazy trying to do something that to me seems like it should be relatively straight forward. In my program (Win32 using Dev-C++ 4.9.9.2) I am trying to take a screenshot of the entire desktop, save it to a
HBITMAP and apply it to a
static control. This is the code I have so far:
1 2 3 4 5 6 7 8 9 10 11 12
|
HWND StaticControl=CreateWindowEx(
0,"Static","",WS_VISIBLE|WS_CHILD|SS_BITMAP,
10,10,800,600,ParentWindow,NULL,hInstance,NULL);//create standard static control
screenDC=GetDC(NULL);//global screen DC
hBitmap=CreateCompatibleBitmap(screenDC,Screen.x,Screen.y);//global HBITMAP
if(hBitmap!=NULL){//check if bitmap is NULL(never is)
SendMessage(StaticControl,STM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBitmap);
}else{
MessageBox(ParentWindow,"bitmap is NULL...","Oh Noes:",MB_OK);
}
|
When my window opens it looks like a normal window (title bar,caption buttons,etc...) and the
static control is there too, but it is completely black. Also the variable
hBitmap is never
NULL.
I have no idea what is going wrong here. I have been able to apply file bitmaps (.bmp's) to a static before using almost the exact same code. I have also tried to paint the
hBitmap using
GDI+, and have achieved similear (all black) results. I would prefer to do this without
GDI+ so that I can add button controls (and the like) and not have to deal with painting .
I do not know where to go from here so if anyone has any suggesstions, it would be much appreciated.
Thanks again for all the help
Sigma