📄 viewlistdlg.cpp
字号:
// ViewListDlg.cpp : implementation file
//
#include "stdafx.h"
#include "IterateViews.h"
#include "ViewListDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CViewListDlg dialog
CViewListDlg::CViewListDlg(CWnd* pParent /*=NULL*/)
: CDialog(CViewListDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CViewListDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CViewListDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CViewListDlg)
DDX_Control(pDX, IDC_VIEWLIST, m_ViewList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CViewListDlg, CDialog)
//{{AFX_MSG_MAP(CViewListDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
///////////////////////////////////////////////////////////
// EkGetActiveDocument : function implementation
//
// Return a pointer to the active document object or NULL
CDocument* EkGetActiveDocument()
{
// 1 - Get a pointer to the application's
// main frame window
CWnd* pWnd = AfxGetMainWnd();
if( pWnd == NULL )
return NULL;
// 2 - Make sure the pointer is valid and more
// strongly typed
ASSERT_VALID( pWnd );
ASSERT_KINDOF( CFrameWnd, pWnd );
CFrameWnd* pMainFrame = static_cast< CFrameWnd* >( pWnd );
// 3 - Get a pointer to the active frame window
// (may be 'this' for SDI application)
CFrameWnd* pActiveFrame = pMainFrame->GetActiveFrame();
if( pActiveFrame == NULL )
return NULL;
// 4 - Return a pointer to the active document object
return pActiveFrame->GetActiveDocument();
}
/////////////////////////////////////////////////////////////////////////////
// CViewListDlg message handlers
BOOL CViewListDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CDocument* pDoc = EkGetActiveDocument();
if( pDoc != NULL )
{
POSITION pos = pDoc->GetFirstViewPosition();
while( pos != NULL )
{
CView* pView = pDoc->GetNextView( pos );
ASSERT_VALID( pView );
// Use pView
CString strViewClass = pView->GetRuntimeClass()->m_lpszClassName;
CString strFrameTitle;
pView->GetParentFrame()->GetWindowText( strFrameTitle );
CString strLine = strViewClass + " in frame [" + strFrameTitle + "]";
m_ViewList.AddString( strLine );
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -