Click here to Skip to main content
15,889,867 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: accelerators and mdi Pin
godzooky20-Oct-03 7:06
godzooky20-Oct-03 7:06 
GeneralRe: accelerators and mdi Pin
Ravi Bhavnani20-Oct-03 7:12
professionalRavi Bhavnani20-Oct-03 7:12 
GeneralRe: accelerators and mdi Pin
godzooky21-Oct-03 2:31
godzooky21-Oct-03 2:31 
GeneralHelp w/ MSI access in VC++ Pin
badsmonkey20-Oct-03 4:24
badsmonkey20-Oct-03 4:24 
GeneralRe: Help w/ MSI access in VC++ Pin
Michael P Butler20-Oct-03 4:42
Michael P Butler20-Oct-03 4:42 
GeneralRe: Help w/ MSI access in VC++ Pin
badsmonkey20-Oct-03 5:18
badsmonkey20-Oct-03 5:18 
GeneralTextArea like in Word Pin
huub20-Oct-03 4:20
huub20-Oct-03 4:20 
GeneralCMDIChildWnd and close-all functionality q. Pin
Maximilien20-Oct-03 3:35
Maximilien20-Oct-03 3:35 
Trying to implement the close all; follow up to a question I posted a few days ago.

When creating the CMDIChildWnd I register them to a list, as you suggested, and when closing them, I unregister them; it's working fine, but if I want to implement the close all window functionality, I will do the following.

The problem is that when the window is closed, it gets unregistered and removed from the list. and when going back to the CloseAllGraphicalWindow, the vector gets invalidated. and BANG !!

Is there something that I missed ?

I know I could hack this; but there should be a better way.

void CMainFrame::CloseAllGraphicalWindow()
{
 ChildWindowVector_t::iterator it = m_ChildWindowVector.begin();
 while (it != m_ChildWindowVector.end() )
 {
  CMDIChildWnd* p = *it;
  p->SendMessage(WM_CLOSE, 0, 0 );
  ++it;
 }
}


LRESULT  CMainFrame::RegisterNewWindow(WPARAM wParam, LPARAM lParam ) 
{
 CMDIChildWnd* pWnd = (CMDIChildWnd*)(lParam);
 ASSERT( pWnd );
 m_ChildWindowVector.push_back( pWnd );
 return 0;
}


LRESULT  CMainFrame::UnRegisterNewWindow(WPARAM wParam, LPARAM lParam ) 
{
 CMDIChildWnd* pWnd = (CMDIChildWnd*)(lParam);
 ASSERT( pWnd );
 ChildWindowVector_t::iterator it = m_ChildWindowVector.begin();
 while (it != m_ChildWindowVector.end() )
 {
  CMDIChildWnd* p = *it;
  if ( p == pWnd )
  {
   m_ChildWindowVector.erase(it);
   return 0;
  }
  ++it;
 }

 // should never be here.
 ASSERT( 0 );
 return 0;
}


Thanks a lot !!



Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
GeneralUNICODE Pin
sinanswedani20-Oct-03 3:13
sinanswedani20-Oct-03 3:13 
GeneralRe: UNICODE Pin
E2120-Oct-03 3:46
E2120-Oct-03 3:46 
GeneralRe: UNICODE Pin
sinanswedani20-Oct-03 4:08
sinanswedani20-Oct-03 4:08 
GeneralRe: UNICODE Pin
E2120-Oct-03 21:52
E2120-Oct-03 21:52 
GeneralRe: how to burn CD Pin
Dominik Reichl20-Oct-03 2:31
Dominik Reichl20-Oct-03 2:31 
GeneralRe: how to burn CD Pin
Rafael Fernández López20-Oct-03 5:46
Rafael Fernández López20-Oct-03 5:46 
GeneralFunction Pin
Anonymous20-Oct-03 2:12
Anonymous20-Oct-03 2:12 
GeneralRe: Function Pin
Alexander M.,20-Oct-03 2:38
Alexander M.,20-Oct-03 2:38 
GeneralFunction Pin
Anonymous20-Oct-03 2:11
Anonymous20-Oct-03 2:11 
GeneralCListCtrl Icon mode Pin
MaxiGroovy20-Oct-03 1:49
MaxiGroovy20-Oct-03 1:49 
GeneralRe: CListCtrl Icon mode Pin
Rafael Fernández López20-Oct-03 2:07
Rafael Fernández López20-Oct-03 2:07 
GeneralRe: CListCtrl Icon mode Pin
MaxiGroovy20-Oct-03 2:15
MaxiGroovy20-Oct-03 2:15 
GeneralRe: CListCtrl Icon mode Pin
Rafael Fernández López20-Oct-03 2:21
Rafael Fernández López20-Oct-03 2:21 
GeneralRe: CListCtrl Icon mode Pin
MaxiGroovy20-Oct-03 2:34
MaxiGroovy20-Oct-03 2:34 
GeneralRe: CListCtrl Icon mode Pin
Rafael Fernández López20-Oct-03 2:41
Rafael Fernández López20-Oct-03 2:41 
GeneralRe: Installing SOAP on 98 / 2000 ... Pin
Anthony_Yio20-Oct-03 1:33
Anthony_Yio20-Oct-03 1:33 
GeneralOpen CView from CMainFrame Pin
XAlien20-Oct-03 0:30
XAlien20-Oct-03 0:30 

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.