|
The way I understand it, anything created with new should be deleted, the destructors in CWnd will be called. Then again, I never tried what your doing. Run the app through the debugger while the app creates these controls. Then exit the app, you will see any memory leaks in the output window if any.
|
|
|
|
|
Call me lazy, but thats why I'm asking...thats why I always ask.
Learn from other peoples mistakes kinda thing...
I ain't getting memory leak detection in output window.
I'm deleting the array...this is OK...but if any of those elements are created controls...i'm curious if I have to call the DestroyWindow().
If when the array is deleted it calls all the destructors then I have nothing to worry about. This is what I don't know. Theres no leaks in the output...so I would have to reply on other tools like stress and resource meter manually watch them go up and down plus i'm super anal and would need to do it and verify about 100 times before I trusted my readings...very time consuming...
So i'm hoping someone will know for sure.
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Deleting the array will call the destructors on all the objects, but I have found that in the past sometimes calling delete on a window and not calling DestroyWindow first causes problems. Having said that, it must be in certain circumstances only, because DestroyWindow is not guarenteed to be called by the MFC framework on it's own windows.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
Don't the CWnd destrcutors call destroywindow() automatically...??
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Not according to MSDN, DestroyWindow destroys the window the CWnd encapsulates, but not the CWnd itself.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
|
|
|
|
|
Christian Graus wrote:
Not according to MSDN, DestroyWindow destroys the window the CWnd encapsulates, but not the CWnd itself.
In his case, when his parent window is destroyed all the child windows are destroyed too. And he calls delete to delete the CWnd object in the destructor. So things should be okay.
Nish
My most recent CP article :-
A newbie's elementary guide to spawning processes
www.busterboy.org
|
|
|
|
|
|
HockeyDude wrote:
when delete is called on the controls pointer do all the CWnd destructors get called automatically...???
Yes they will be called but IMO before that you will have to remove the windows from screen.
From MSDN:
"In the MFC framework, when the user closes the frame window, the window’s defaultOnClose handler callsDestroyWindow."
HockeyDude wrote:
Would I have to call the controls destroyWindow functions..??
From MSDN:
"Do not use the C++ delete operator to destroy a frame window or view. Instead, call the CWnd member function DestroyWindow. Frame windows, therefore, should be allocated on the heap with operator new."
Atul
|
|
|
|
|
|
Yes Nish you are correct I was talking about CButton.
I was positive that destructors were called with delete, but you and christian have helped me verify with myself.
Although what Christian said about DestroyWindow not being called kinda has me worried, i'd hate to have a bunch of HWND's lingering around after there CWnd is bye bye.
Ahh..to hell with it...i'm take the leakage if there is any...
Thanx !
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
All I needed to hear...
Thanx Nish!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Oops a daisy!...you are right...
Sorry...must have been daydreaming...
Atul
sleep...sleep...sleep...
|
|
|
|
|
I set my pointer to a window by doing
CWnd * Handle=FindWindow("AIM_IMessage",NULL);
and now i want to do a
SetWindowText("Some text") ;
or a
::SendMessage(HWND Hand...);
Only thing is, I don't know how to specify that I want my pointer to be where it sends the text... Or for that matter send it to a child window of the window that the pointer is pointing to...
Either way
Can anyone help me out?
|
|
|
|
|
Hi,
I'm not quite sure what you're asking, but if your CWnd * is valid (ie it's not NULL), then you can either do:
CWnd *pMyWindow = FindWindow("AIM_IMessage", NULL);
pMyWindow->SetWindowText("Some Text");
or
pMyWindow->SendMessage(params)
By the way, if you need a HWND for the window you've got a pointer to, just call:
pMyWindow->GetSafeHwnd();
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
|
Hi, I have a dialog with a couple of textboxes on it, and I want to change
the font size on one of the terxtboxes. I can't seem to find out how. Any
input would be great. Thanks
|
|
|
|
|
Have you tried SetFont?
void CMyDialogClass::SetTheFonts()
{
m_fntBigFont.CreatePointFont(24, _T("Arial"));
m_fntLittleFont.CreatePointFont(6, _T("Arial"));
m_edtBigEditControl.SetFont(&m_fntBigFont);
m_edtLittleEditControl.SetFont(&m_fntLittleFont);
}
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
|
|
I have created a mfc project and within this I have created a dialoguebar and multiple document view windows. When I click on a button on my dialoguebar how can I get the current document object as it has a Carray object which I would like to obtain.
Thank you in advance.
|
|
|
|
|
That depends on where you are handling the button click. If the dialog bar is part of the main frame class, you can try:
CMainFrame::OnPressMyButton()
{
CMDIChildWnd *vpChildFrame = MDIGetActive();
if (vpChildFrame != NULL)
{
CDocument *vpActiveDocument = vpChildFrame->GetActiveDocument();
if (vpActiveDocument != NULL)
{
DoSomeStuffWith(vpActiveDocument);
}
}
}
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Hi. I am writing a dll that attaches to a program with no debug info. When I set an breakpoint in my code it does not stop at the breakpoint, it just ignores it and continues on it's merry way. If I put in __asm int 3 to force a breakpoint, it works and puts me in my code at the int 3 line. This is my second DLL where this problem has crept up.
Does anyone know why the visual c++ breakpoints are broken? (pun intended)
Thanks,
Clint
PS. If you were going to ask. Yes, I am in debug mode with my code.
|
|
|
|
|
I always thought breakpoints were disabled in release mode.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
How have you got the debugging session configured?
I assume you have the DLL as the loaded project in VC and are using the exe as the "Executable for debug session".
This should work providing you have the dll compiled with the debug info.
Michael
|
|
|
|