Click here to Skip to main content
16,007,858 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralPeer-to-Peer with Windows-Sockets Pin
18-May-01 5:25
suss18-May-01 5:25 
GeneralRe: Peer-to-Peer with Windows-Sockets Pin
18-May-01 6:50
suss18-May-01 6:50 
Generalcapture a rectangle in a static image and resize it in another window Pin
Frederico Levesque18-May-01 4:44
Frederico Levesque18-May-01 4:44 
GeneralRe: capture a rectangle in a static image and resize it in another window Pin
18-May-01 5:08
suss18-May-01 5:08 
GeneralClasses, new, delete, destructors Pin
José Luis Sogorb18-May-01 4:41
José Luis Sogorb18-May-01 4:41 
GeneralRe: Classes, new, delete, destructors Pin
James R. Twine18-May-01 4:50
James R. Twine18-May-01 4:50 
GeneralRe: Classes, new, delete, destructors Pin
José Luis Sogorb18-May-01 5:16
José Luis Sogorb18-May-01 5:16 
GeneralRe: Classes, new, delete, destructors Pin
James R. Twine18-May-01 8:32
James R. Twine18-May-01 8:32 
> WELL, THIS IS THE FUNCTION DRAWING GRAPHIC [...]

   Whenever you call CDC::SelectObject(...), you need to store the object that is returned from that function call, and restore it back into the GDI context.  Also, deleting a GDI object while it is still Selected into a Device Context (DC) is a bad thing.

   My suggestions would be to:
     1: Keep track of the objects returned from the call to SelectObject(...), or take a look at the SaveDC(...) and RestoreDC(...) functions.  You will need to make sure to restore previously selected objects back into the DC before you delete the CGdiObjects that are currently selected into it.
     2: Do not use dynamic memory allocation for the temporary GDI objects you are using (the CPen and CFont objects). Allocate them locally, on the stack, and just reuse them as needed.

   Peace!

-=- James.
GeneralRe: Classes, new, delete, destructors Pin
José Luis Sogorb18-May-01 9:40
José Luis Sogorb18-May-01 9:40 
GeneralRe: Classes, new, delete, destructors Pin
James R. Twine18-May-01 10:14
James R. Twine18-May-01 10:14 
GeneralRe: Classes, new, delete, destructors Pin
José Luis Sogorb18-May-01 23:22
José Luis Sogorb18-May-01 23:22 
GeneralRe: Classes, new, delete, destructors Pin
James R. Twine19-May-01 2:16
James R. Twine19-May-01 2:16 
GeneralMailslot Problem Pin
18-May-01 4:27
suss18-May-01 4:27 
GeneralGeneral Question Pin
mr200318-May-01 4:11
mr200318-May-01 4:11 
GeneralRe: General Question Pin
Stan Shannon18-May-01 9:45
Stan Shannon18-May-01 9:45 
GeneralMemory Mapped Files and Security under IIS 5.0 / Win2K... Pin
James R. Twine18-May-01 3:15
James R. Twine18-May-01 3:15 
GeneralDrag and Drop Pin
Eran18-May-01 2:55
Eran18-May-01 2:55 
GeneralRe: Drag and Drop Pin
Tomasz Sowinski18-May-01 3:06
Tomasz Sowinski18-May-01 3:06 
GeneralTCP/IP Socket programming Pin
Gerry18-May-01 2:03
Gerry18-May-01 2:03 
GeneralRe: TCP/IP Socket programming Pin
18-May-01 2:29
suss18-May-01 2:29 
GeneralRe: TCP/IP Socket programming Pin
Gerry18-May-01 2:45
Gerry18-May-01 2:45 
GeneralRe: TCP/IP Socket programming Pin
markkuk20-May-01 21:06
markkuk20-May-01 21:06 
QuestionCPrintDialog::GetDefaults() doesn't work? Pin
Joep18-May-01 1:31
Joep18-May-01 1:31 
AnswerRe: CPrintDialog::GetDefaults() doesn't work? Pin
Gerry18-May-01 3:21
Gerry18-May-01 3:21 
GeneralUnsing STL in cunjunction with MFC Pin
18-May-01 1:19
suss18-May-01 1:19 

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.