how to close a form?
-
hi all, I'am having a new tool bar with 5 buttons in my appication. Each button opens a form. Now i should like to know how to automatically close the first form, when second form is opening ? like wise for all forms. so at present time only one form should be visible. can u please answer this question. thanks panthal
-
hi all, I'am having a new tool bar with 5 buttons in my appication. Each button opens a form. Now i should like to know how to automatically close the first form, when second form is opening ? like wise for all forms. so at present time only one form should be visible. can u please answer this question. thanks panthal
You can send WM_CLOSE to them,how did you make them?
-
You can send WM_CLOSE to them,how did you make them?
-
thanks for your reply, i'll try this. but How to send WM_CLOSE can u explain clearly please R u asking about that tool bar buttons?
You must use of SendMessage.
-
hi all, I'am having a new tool bar with 5 buttons in my appication. Each button opens a form. Now i should like to know how to automatically close the first form, when second form is opening ? like wise for all forms. so at present time only one form should be visible. can u please answer this question. thanks panthal
There is more than a solution. I make it like this.
void CMainFrame::CloseMyFrame ()
{ //Get necessary connections
CMDIChildWnd* pMDIActive = MDIGetActive();
CDocument* pDoc = pMDIActive->GetActiveDocument();
CMyView* pMyView;POSITION pos = pDoc->GetFirstViewPosition(); while (pos) { pMyView = (CMyView\*) pDoc->GetNextView(pos); if (pMyView->IsKindOf(RUNTIME\_CLASS(CMyView))) { CFrameWnd\* pTempFrame = pMyView->GetParentFrame (); pTempFrame->DestroyWindow (); return; } } return;
}
And, when I want to use it...
extern CFPSApp theApp;
CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
pFrame->CloseMyFrame ();I forgot... I make it to close a specific Frame (that may be only ONCE at a time) For other that I may be more times at once opened, I like follows
void CMainFrame::CloseMyFrame (CString szName)
//....
if ((pMyView->IsKindOf(RUNTIME_CLASS(CMyOtherView))) && (pMyView->m_pParent->m_szName == szName))
//...This is because I use that views to modifify the parameters of an element. So I hold a pointer to the element that is being shown as a member variable in every window. So I get easy access to the data I have to show/modify and use it to differenciate between the 48 possible CFormViews that can be opened at once.
Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson