Click here to Skip to main content
15,902,635 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionArray Pin
john563221-Sep-08 19:25
john563221-Sep-08 19:25 
AnswerRe: Array [modified] Pin
enhzflep21-Sep-08 19:51
enhzflep21-Sep-08 19:51 
QuestionHow to a webserver in VC++ Pin
tns_ranjith21-Sep-08 19:19
tns_ranjith21-Sep-08 19:19 
AnswerRe: How to a webserver in VC++ Pin
Hamid_RT21-Sep-08 19:56
Hamid_RT21-Sep-08 19:56 
AnswerRe: How to a webserver in VC++ Pin
nguyenbinh0721-Sep-08 22:43
nguyenbinh0721-Sep-08 22:43 
QuestionHow to convert HDC to CBitmap? Pin
TooShy2Talk21-Sep-08 16:23
TooShy2Talk21-Sep-08 16:23 
AnswerRe: How to convert HDC to CBitmap? Pin
Hamid_RT21-Sep-08 20:05
Hamid_RT21-Sep-08 20:05 
AnswerRe: How to convert HDC to CBitmap? Pin
enhzflep21-Sep-08 20:43
enhzflep21-Sep-08 20:43 
Here's some code that will retrieve the currently selected bitmap from a HDC.
It should be noted that GetCurrentObject will only return a valid BITMAP if the supplpied HDC is a memory DC.
If I tried to do dcBmp = (HBITMAP)GetCurrentObject(screenDC, OBJ_BITMAP), I'd get garbage results.

If the DC you're trying to copy is not a memory DC, the alternative you have is to determine the position on screen of the image, then do a BitBlt from the screenDC to a memoryDC that has already got a HBITMAP selected onto it.

Note that having a look into the BitBlt, SelectObject, & CreateCompatibleBitmap may be necessary.


HDC screenDC, memDC;
char buffer[200];
BITMAP bmInfo;
HBITMAP dcBmp;

screenDC = GetWindowDC(hwnd);
memDC = CreateCompatibleDC(screenDC);
HBITMAP myBmp = CreateCompatibleBitmap(memDC, 100, 100);
SelectObject(memDC, myBmp);

dcBmp = (HBITMAP)GetCurrentObject(memDC, OBJ_BITMAP);
if (dcBmp)
{
    GetObject(dcBmp, sizeof(bmInfo), &bmInfo);
    sprintf(buffer, "Bitmap is: %d x %d pixels.", bmInfo.bmWidth, bmInfo.bmHeight);
    MessageBox(hwnd, buffer, "Title", MB_OK);
}
else
    MessageBox(hwnd, "Error", "Title", MB_ICONEXCLAMATION);

QuestionNeed a help with TreeListView realization on C++ Winapi (without MFC) Pin
sax_0H21-Sep-08 11:13
sax_0H21-Sep-08 11:13 
AnswerRe: Need a help with TreeListView realization on C++ Winapi (without MFC) Pin
Mark Salsbery21-Sep-08 14:41
Mark Salsbery21-Sep-08 14:41 
GeneralRe: Need a help with TreeListView realization on C++ Winapi (without MFC) Pin
sax_0H21-Sep-08 19:03
sax_0H21-Sep-08 19:03 
Questionerror concerning _TEMPLATE_MEMBER Pin
steph521-Sep-08 7:09
steph521-Sep-08 7:09 
QuestionHow - to hide the mouse pointer - MFC Pin
simon alec smith21-Sep-08 5:24
simon alec smith21-Sep-08 5:24 
AnswerRe: How - to hide the mouse pointer - MFC Pin
Mark Salsbery21-Sep-08 6:33
Mark Salsbery21-Sep-08 6:33 
GeneralRe: How - to hide the mouse pointer - MFC Pin
simon alec smith22-Sep-08 4:55
simon alec smith22-Sep-08 4:55 
QuestionHow change frame color style ? Pin
ta_isr21-Sep-08 1:32
ta_isr21-Sep-08 1:32 
AnswerRe: How change frame color style ? Pin
Mark Salsbery21-Sep-08 6:40
Mark Salsbery21-Sep-08 6:40 
Questiontemplate class inheritance issue Pin
George_George20-Sep-08 22:03
George_George20-Sep-08 22:03 
QuestionRe: template class inheritance issue Pin
Nemanja Trifunovic21-Sep-08 13:56
Nemanja Trifunovic21-Sep-08 13:56 
AnswerRe: template class inheritance issue Pin
George_George21-Sep-08 19:52
George_George21-Sep-08 19:52 
GeneralRe: template class inheritance issue Pin
CPallini21-Sep-08 21:43
mveCPallini21-Sep-08 21:43 
GeneralRe: template class inheritance issue Pin
George_George21-Sep-08 22:16
George_George21-Sep-08 22:16 
GeneralRe: template class inheritance issue Pin
CPallini21-Sep-08 22:44
mveCPallini21-Sep-08 22:44 
GeneralRe: template class inheritance issue Pin
George_George21-Sep-08 23:01
George_George21-Sep-08 23:01 
AnswerRe: template class inheritance issue Pin
Malli_S21-Sep-08 19:36
Malli_S21-Sep-08 19:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.