Click here to Skip to main content
15,901,373 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: ListCtrl on VC7 Pin
David Crow7-Nov-06 2:54
David Crow7-Nov-06 2:54 
QuestionWant to control a plugged in USB storage drive Pin
Biju Raman7-Nov-06 0:57
Biju Raman7-Nov-06 0:57 
AnswerRe: Want to control a plugged in USB storage drive Pin
Cedric Moonen7-Nov-06 1:35
Cedric Moonen7-Nov-06 1:35 
GeneralRe: Want to control a plugged in USB storage drive Pin
Biju Raman30-Nov-06 0:39
Biju Raman30-Nov-06 0:39 
QuestionDraw something on CreateDC()'s HDC Pin
Toubou7-Nov-06 0:30
Toubou7-Nov-06 0:30 
AnswerRe: Draw something on CreateDC()'s HDC Pin
Steve S7-Nov-06 0:58
Steve S7-Nov-06 0:58 
GeneralRe: Draw something on CreateDC()'s HDC Pin
Toubou7-Nov-06 1:30
Toubou7-Nov-06 1:30 
GeneralRe: Draw something on CreateDC()'s HDC Pin
Steve S7-Nov-06 2:45
Steve S7-Nov-06 2:45 
If you want to create a memory DC to keep the image in, you need to do something like this:

HDC wDC = ::GetDC(m_hWnd);
HDC memDC = ::CreateCompatibleDC(wDC);
HBITMAP hBMP = ::CreateCompatibleBitmap(wDC, 500,500); // or whichever size

hBmp = (HBITMAP)SelectObject(memDC, hBMP);
// Now do your drawing to your memory DC

// Now do your BitBlt

// And tidy up..
ReleaseDC(m_hWnd, wDC);

// To clean up memory DC
hBMP = (HBITMAP)SelectObject(memDC, hBMP); // Restore 1x1 bitmap
DeleteObject(hBMP);
DeleteDC(memDC);

The DC is a precious resource. Using CreateDC("DISPLAY",..) just to get a DC to create a screen-compatible DC when you have a window is wasteful, your code did not have a way to delete the DC you created in this way. If you don't clean up, you'll run out of DCs. Maybe not today, maybe not tomorrow, but soon.

You probably want to make the bitmap and memory dc handles member variables for the dialog object class.

HTH

Steve S
Developer for hire

GeneralRe: Draw something on CreateDC()'s HDC Pin
Toubou7-Nov-06 4:20
Toubou7-Nov-06 4:20 
AnswerRe: Draw something on CreateDC()'s HDC Pin
Hamid_RT7-Nov-06 7:11
Hamid_RT7-Nov-06 7:11 
JokeRe: Draw something on CreateDC()'s HDC Pin
Steve S7-Nov-06 7:24
Steve S7-Nov-06 7:24 
Questionmoving mouse cursor using WIN32 Pin
priyank_ldce7-Nov-06 0:16
priyank_ldce7-Nov-06 0:16 
AnswerRe: moving mouse cursor using WIN32 Pin
Nibu babu thomas7-Nov-06 0:45
Nibu babu thomas7-Nov-06 0:45 
Questionchanging color of static text Pin
Kiran Pinjala7-Nov-06 0:12
Kiran Pinjala7-Nov-06 0:12 
AnswerRe: changing color of static text Pin
Nibu babu thomas7-Nov-06 0:47
Nibu babu thomas7-Nov-06 0:47 
AnswerRe: changing color of static text Pin
Hamid_RT7-Nov-06 1:08
Hamid_RT7-Nov-06 1:08 
AnswerRe: changing color of static text Pin
David Crow7-Nov-06 2:56
David Crow7-Nov-06 2:56 
QuestionChecking an IP Address in Network? Pin
Andy Rama7-Nov-06 0:10
Andy Rama7-Nov-06 0:10 
AnswerRe: Checking an IP Address in Network? Pin
Nibu babu thomas7-Nov-06 0:56
Nibu babu thomas7-Nov-06 0:56 
GeneralRe: Checking an IP Address in Network? Pin
Andy Rama7-Nov-06 1:58
Andy Rama7-Nov-06 1:58 
GeneralRe: Checking an IP Address in Network? Pin
Andy Rama7-Nov-06 20:06
Andy Rama7-Nov-06 20:06 
GeneralRe: Checking an IP Address in Network? Pin
Nibu babu thomas7-Nov-06 20:54
Nibu babu thomas7-Nov-06 20:54 
GeneralRe: Checking an IP Address in Network? Pin
Andy Rama9-Nov-06 18:27
Andy Rama9-Nov-06 18:27 
GeneralRe: Checking an IP Address in Network? Pin
Nibu babu thomas9-Nov-06 18:33
Nibu babu thomas9-Nov-06 18:33 
QuestionOpen Explorer from VC++ application.... Pin
klvin6-Nov-06 23:50
klvin6-Nov-06 23:50 

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.