Click here to Skip to main content
15,894,343 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: TabCtrl Pin
Michael Dunn26-Sep-01 15:51
sitebuilderMichael Dunn26-Sep-01 15:51 
QuestionHOWTO: Find owner of locked file? Pin
Matt Weagle26-Sep-01 8:00
Matt Weagle26-Sep-01 8:00 
GeneralDirectX Beginner Pin
Mr_Byte26-Sep-01 6:45
Mr_Byte26-Sep-01 6:45 
GeneralRe: DirectX Beginner Pin
26-Sep-01 6:47
suss26-Sep-01 6:47 
GeneralRe: DirectX Beginner Pin
Mr_Byte26-Sep-01 6:53
Mr_Byte26-Sep-01 6:53 
GeneralRe: DirectX Beginner Pin
26-Sep-01 6:59
suss26-Sep-01 6:59 
GeneralRe: DirectX Beginner Pin
Mr_Byte26-Sep-01 7:12
Mr_Byte26-Sep-01 7:12 
GeneralCDC Resource/Memor Leaks... (continued)... Pin
26-Sep-01 6:42
suss26-Sep-01 6:42 
I may be confusing my memory leak with a resource leak. In any case,
what is happening is that I have setup CRect’s within my dialog window
as the actual areas that I’ll be bltting to.
The program seems to work fine for awhile, however, after
executing the program 20-30 times (opening and closing the app), the
areas (CRects) that had once successfully been bltted, do not show
anything anymore, but only the default gray background. …only rebooting
solves problem. A sign of leakage somewhere?

Another difference I’ve been noticing is that I did my initialization
inside my InitDialog() function and not OnCreate(). Important? I don’t
know…

Here’s some of my initialization code:
/////////////////  Inside InitDialog()
CRect rectDialog;
GetClientRect(&rectDialog);
rectDialog.NormalizeRect();

m_rectZoom.SetRect(rectDialog.left + 250,
		           rectDialog.top + 50,
		           rectDialog.left + 700,
		           rectDialog.top + 500);
m_rectZoom.NormalizeRect();

m_rectHead0.SetRect(rectDialog.left + 50,    
 		            rectDialog.top + 100,
			rectDialog.left + 200,
			rectDialog.top + 250);
m_rectHead0.NormalizeRect();
  
m_rectHead0Source.SetRect(0,0,2000,2000);
m_rectHead0Source.NormalizeRect();

m_rectZoomSource.SetRect(0,0,2000,2000);
m_rectZoomSource.NormalizeRect();

pDC = this->GetDC();
m_dcHead0 = new CMemDC(pDC, m_rectHead0Source);
// yes this is deleted upon exit of program
this->ReleaseDC(pDC);


Of course I left a lot of my code out, but hopefully this may give you
an idea of where I’m at. My OnPaint() got somwhat complicated, so I’ll
try to paraphrase…

On the first call of OnPaint() I draw an ellipse to m_dcHead0 and
StretchBlt that to my paintDC (a’la the pointer returned by BeginPaint
(&PAINTSTRUCT) ). Depending on where my mouse is clicked, I StretchBlt a
portion of m_dcHead0 to the m_dcZoom.

That’s really making a long story short. Please don’t break your back
looking over my code. I was just hoping for some quick ideas, I’d
rather not have you finish my work. Your help has been much appreciated.

-t²


>Oh - ok - I make a distiction between resource leaks and memory leaks - >perhaps what you have is a resource leak.
>
>If you are working with classes derived from CGdiObject (like CBrush, >CPen) the ~CGdiObject destructor should free the resource for you - so >when the testBrush goes out of scope, or its containing class is >destroyed, you should be ok. MFC will ASSERT in debug mode if you try >to call CreateBrush or CreatePen twice without calling DeleteObject.
>
>If you are working with handles returned from say, a call >to ::CreateBrushIndirect (not using CBrush) you must be careful to >destroy the object (after deselecting it from the DC).
>
>What is telling you that you have the leak? - I thought it was a dump >provided by the debug C runtime allocation routines - in which case the >allocation number would be the one in curly braces.
>
>Say - since this thread is getting kind of buried now, why don't you >post a bit of code (showing your SaveDC and RestoreDC calls and stuff >that you are doing in between) in a new thread - rem - use
and >
to surround your code - if its a resource leak, it may not be >obvious - I seem to recall some subtle gotchas that have appeared in >these posts - but I bet you'll get a helpful answer real quick.
GeneralRe: CDC Resource/Memor Leaks... (continued)... Pin
Tomasz Sowinski26-Sep-01 6:50
Tomasz Sowinski26-Sep-01 6:50 
GeneralRe: CDC Resource/Memor Leaks... (continued)... Pin
26-Sep-01 8:18
suss26-Sep-01 8:18 
GeneralRe: CDC Resource/Memor Leaks... (continued)... Pin
Tomasz Sowinski26-Sep-01 8:23
Tomasz Sowinski26-Sep-01 8:23 
GeneralRe: CDC Resource/Memor Leaks... (continued)... Pin
26-Sep-01 8:32
suss26-Sep-01 8:32 
GeneralRe: CDC Resource/Memor Leaks... (continued)... Pin
Tomasz Sowinski26-Sep-01 8:39
Tomasz Sowinski26-Sep-01 8:39 
GeneralExport function Pin
Jose Fco Bonnin26-Sep-01 4:49
Jose Fco Bonnin26-Sep-01 4:49 
GeneralRe: Export function Pin
Michael P Butler26-Sep-01 4:59
Michael P Butler26-Sep-01 4:59 
GeneralRe: Export function Pin
Jose Fco Bonnin26-Sep-01 5:22
Jose Fco Bonnin26-Sep-01 5:22 
GeneralRe: Export function Pin
Carlos Antollini26-Sep-01 6:02
Carlos Antollini26-Sep-01 6:02 
GeneralRe: Export function Pin
Rashid Thadha26-Sep-01 11:36
Rashid Thadha26-Sep-01 11:36 
GeneralAudio program works under Win2k but not Win98 Pin
groston26-Sep-01 4:47
groston26-Sep-01 4:47 
GeneralCListCtl Pin
otvac26-Sep-01 4:29
otvac26-Sep-01 4:29 
GeneralRe: CListCtl Pin
Michael P Butler26-Sep-01 5:02
Michael P Butler26-Sep-01 5:02 
GeneralRe: CListCtl Pin
Tomasz Sowinski26-Sep-01 6:43
Tomasz Sowinski26-Sep-01 6:43 
GeneralRe: CListCtl Pin
Michael P Butler26-Sep-01 8:37
Michael P Butler26-Sep-01 8:37 
GeneralRe: CListCtl Pin
Tomasz Sowinski26-Sep-01 8:47
Tomasz Sowinski26-Sep-01 8:47 
GeneralRe: CListCtl Pin
Rashid Thadha26-Sep-01 11:32
Rashid Thadha26-Sep-01 11:32 

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.