我在程序中定义了CGraphView和CTextView两个视图,同时
pDocTemplate = new CMultiDocTemplate(
IDR_GRAPHTYPE,
RUNTIME_CLASS(CGraphDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CGraphView));
AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate(
IDR_GRAPHTYPE,
RUNTIME_CLASS(CGraphDoc),
RUNTIME_CLASS(CMDIChildWnd),
RUNTIME_CLASS(CSingleTextView));
AddDocTemplate(pDocTemplate);
然后定义了一个菜单NewWindowSingle,类似于New Window的功能,主要新建一个CTextView视图
我想问一下如何在新建CTextView时候,将开始打开的视图关闭?请各位高人指点不胜感激。
pDocTemplate = new CMultiDocTemplate(
IDR_GRAPHTYPE,
RUNTIME_CLASS(CGraphDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CGraphView));
AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate(
IDR_GRAPHTYPE,
RUNTIME_CLASS(CGraphDoc),
RUNTIME_CLASS(CMDIChildWnd),
RUNTIME_CLASS(CSingleTextView));
AddDocTemplate(pDocTemplate);
然后定义了一个菜单NewWindowSingle,类似于New Window的功能,主要新建一个CTextView视图
我想问一下如何在新建CTextView时候,将开始打开的视图关闭?请各位高人指点不胜感激。
::SendMessage(MDIGetActive()->GetSafeHwnd(),WM_CLOSE,0,0);试了一下
好像只是关闭当前新建的窗口
{
CView * pView = pFrame->GetActiveView();
if(pView->IsKindOf( RUNTIME_CLASS( CTextView ))
{ ((CCMDIChildWnd*)pFrame)->MDIDestroy(); }
}// 关闭某个子窗口的方法,自己去写,不过我大致写了一下,应该可以。
在EnumChildProc里::PostMessage(hWnd,WM_CLOSE,0,0);EnumChildWindows
The EnumChildWindows function enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE. BOOL EnumChildWindows(
HWND hWndParent, // handle to parent window
WNDENUMPROC lpEnumFunc, // pointer to callback function
LPARAM lParam // application-defined value
);EnumChildProc
The EnumChildProc function is an application-defined callback function used with the EnumChildWindows function. It receives the child window handles. The WNDENUMPROC type defines a pointer to this callback function. EnumChildProc is a placeholder for the application-defined function name. BOOL CALLBACK EnumChildProc(
HWND hwnd, // handle to child window
LPARAM lParam // application-defined value
);
将EnumDesktopWindows换成EnumChildWindows,将你一个参数改为主窗口句柄