CDocTemplate::GetFirstDocPosition,Use the POSITION value as an argument to CDocTemplate::GetNextDoc to iterate through the list of documents associated with the template. to each document use CDocument::GetFirstViewPosition which returns a POSITION value that can be used for iteration with the CDocument::GetNextView function.
我以为大家都知道CView有一个public属性叫m_hWnd. 我也以为大家都知道通过sdk函数 BOOL ShowWindow( HWND hWnd, // handle to window int nCmdShow // show state ); 操作窗口。 实际上还应该枚举所有文档模板。 MDI程序具有一个或多个文档模板, 每个文档模板具有一个或多个文档实例, 每个文档实例具有一个或多个视图。楼主会用就行了。
to each document use
CDocument::GetFirstViewPosition which returns a POSITION value that can be used for iteration with the CDocument::GetNextView function.
我也以为大家都知道通过sdk函数
BOOL ShowWindow(
HWND hWnd, // handle to window
int nCmdShow // show state
);
操作窗口。
实际上还应该枚举所有文档模板。
MDI程序具有一个或多个文档模板,
每个文档模板具有一个或多个文档实例,
每个文档实例具有一个或多个视图。楼主会用就行了。
POSITION pos;
CEVITDocTemplate *p = NULL; CString strTitle;
pos = GetFirstDocTemplatePosition();
while(pos != NULL)
{
p = (CEVITDocTemplate*)GetNextDocTemplate(pos);
if(p->m_pFrame != NULL)
{
p->m_pFrame->SendMessage(WM_CLOSE);
}
}你可能会奇怪m_pFrame哪来的?
CEVITDocTemplate是我从CMultiDocTemplate派生来的,m_pFrame是CChildFrame,而且我还重载了CMultiDocTemplate::CreateNewFrameCFrameWnd* CEVITDocTemplate::CreateNewFrame(CDocument *pDoc, CFrameWnd *pOther)
{
m_pFrame = CMultiDocTemplate::CreateNewFrame(pDoc, pOther);
return m_pFrame;
}OK,不?