The CString does not only contain a pointer to a character array, but also more information such as allocation size and length of current data. If you use a CString as an argument you will push all that to the stack, when in fact you only want the pointer to the character array on the stack, as described by the format specifiers to CString::Format(). You will simply mess up the arguments/stack. Do the conversion I suggested in the answer above to avoid this.
This is one reason to avoid variable arguments whenever possible. The compiler cannot perform type checks.
I am using visual studio 2010 and sometimes when i try to create a variable using add member variable wizard, it is not created. Try again and again and it is not created make a new dialog box and a new control then it is created.
The wizards are generally unreliable, they're buggy, specially if you mess with any of the code they've generated (and the text comments/tags it inserts for itself). My recommendation, learn to do everything without wizards. It'll make you an overall better developer and will keep you from relying on something that works part of the time.
Means you're probably forgetting to do something. I do this by hand all the time, and unlike the wizards, it works every time. Like I said, nothing wrong with using the wizards, but they're not the most reliable thing ever implemented.
In my application for one child window,im having more than 100 pages.When page up and page down im moving coresponding next pages.BEfore getting next page, im destroying the previous page by using DestroyWindow.
But when i see in the Task Manager,Perormance Tab,The PF usage shows for every page it increasing 0.01GB and in Physical Memory(K)-Available the number(ex:1571826)is getting reduced and soon one error is coming like
"Out of memory,edit".
Im pasting here my PageUp and Pagedown code:
void CGraphView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
if(nChar == 33 || nChar == 34)
short iTempPgNo = ((CMainFrame*)AfxGetMainWnd())->m_ngiSchPNo;
if(nChar == 33)
if(iTempPgNo != m_ngiSchPNo)
if( gpGView[nCurrGrpView]->glg_animation[giSchPNo].m_hWnd )
gpGView[nCurrGrpView]->glg_animation[giSchPNo].DestroyWindow(); //Destroying previous page.
giSchPNo = iTempPgNo; //assigning new page number to giSchPNo varible,im using this variable in OnDraw() to get new page.if(giSchPNo > giGraphicCnt)
giSchPNo = giGraphicCnt;
((CMainFrame*)AfxGetMainWnd())->m_ngiSchPNo = giSchPNo;
CView::OnKeyDown(nChar, nRepCnt, nFlags);
Eventhough im using DestroyWindow(),why the memory is getting increased for each page down.
Only frame windows destroy their associated C++ object when DestroyWindow is called. With CWnd-derived windows only the Windows UI HWND is destroyed when DestroyWindow is called. Do you need to delete a CWnd object too or are you reusing them? Or are they frame windows?
after destroying this window, are you still using glg_animation[giSchPNo] object ? What if user visits this page again? Do you create glg_animation[giSchPNo] window?
And it would be better if you post your paint event function too.
Apart from this, I noticed that you are using an array to hold the number of pages and destroying each window after page is scrolled. This shows that you'll be holding one page in the memory, then why are you using an array? Instead, you can create the page objects dynamically.
Check whether the create() function is successful, or you may end up in creating the window every time you enter paint event which will run your app out to memory soon.
Try using the single glg_animation instead of an array, as you're creating / deleting the pages dynamically. This will reduce your memory usage, as at a time only one object will be in use from an array.