VS 2010 단일 문서 + 다 중 보기 + Outlook 스타일
7772 단어 VS2010
, , 。 , 。 , , 。 , , 。 , 。 , , 。 , , 。 , 。
장 난 스 러 운 분할 선Outlook 스타일 은 http://blog.csdn.net/wlsgzl/article/details/32083145 에서 이미 실현 되 었 습 니 다. 여 기 는 다 중 보기 만 할 수 있 습 니 다.
= = = = = = = = 쌍 입 쌍 의 분할 선 이 부 럽 습 니 다 = = = = = = = = = = = =
먼저 VS 2010 이 준 예시 코드 아웃 룩 MultiViews 를 분석 하고 관련 부분 을 살 펴 보 자.
COutlook MultiViewsApp 의 Init Instance 에서
CSingleDocTemplate 의 구조 함수 의 네 번 째 매개 변 수 를 자신의 클래스 로 변경 합 니 다.
BOOL COutlookMultiViewsApp::InitInstance()
{
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Microsoft\\MFC\\Samples"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
SetRegistryBase (_T("Settings"));
// Initialize all Managers for usage. They are automatically constructed
// if not yet present
InitContextMenuManager();
InitKeyboardManager();
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(COutlookMultiViewsDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(/*COutlookMultiViewsView*/CFV1));//
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
주 프레임 창 클래스 CMainFrame 의 보기 구성원 변수
// Array of views attached to single document
CView * m_pViews[NUMVIEWS];
// Index to current view
UINT m_nCurView;
CMainFrame 의 InitViews 에서
void CMainFrame::InitViews ()
{
m_nCurView = 0; // Save index of the currently active view class
CView* pActiveView = GetActiveView();
m_pViews[0] = pActiveView;// MFC
// m_pViews[1] = (CView*) new CView1;
// m_pViews[2] = (CView*) new CView2;
// m_pViews[3] = (CView*) new CView3;
m_pViews[1] = (CView*) new CFV2;// , CFormView
m_pViews[2] = (CView*) new CFV3;// , CFormView
m_pViews[3] = (CView*) new CFV4;// , CFormView
CDocument* pCurrentDoc = GetActiveDocument();
// Initialize a CCreateContext to point to the active document.
// With this context, the new view is added to the document
// when the view is created in CView::OnCreate().
CCreateContext newContext;
newContext.m_pNewViewClass = NULL;
newContext.m_pNewDocTemplate = NULL;
newContext.m_pLastView = NULL;
newContext.m_pCurrentFrame = NULL;
newContext.m_pCurrentDoc = pCurrentDoc;
CRect rect(0, 0, 0, 0); // gets resized later
for (int nView = 1; nView < NUMVIEWS; nView++)
{
// Create the new view. In this example, the view persists for
// the life of the application. The application automatically
// deletes the view when the application is closed.
m_pViews[nView]->Create(NULL, NULL,
(AFX_WS_DEFAULT_VIEW & ~WS_VISIBLE),
// views are created with the style of AFX_WS_DEFAULT_VIEW
// In MFC 4.0, this is (WS_BORDER | WS_VISIBLE | WS_CHILD)
rect, this,
IDD_FORMVIEW1-1 + nView, &newContext);// ID ( resource.h ), 。
// When a document template creates a view, the WM_INITIALUPDATE
// message is sent automatically. However, this code must
// explicitly send the message, as follows.
//m_pViews [nView]->OnInitialUpdate();// , CFormView , 。
}
}
그리고 COutlook MultiViews App 의 InitInstance 에 InitViews 호출 을 추가 합 니 다.
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
((CMainFrame*)m_pMainWnd)->InitViews ();// InitViews
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
CMainFrame 메시지 맵 매크로 에서
이 건 수 동 으로 추 가 된 것 같 아 요. 위 저 드 는 ON 을 추가 할 수 없 으 니까 요.COMMAND_RANGE 의 매크로, 마치.
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
ON_COMMAND(ID_VIEW_CUSTOMIZE, OnViewCustomize)
ON_REGISTERED_MESSAGE(AFX_WM_RESETTOOLBAR, OnToolbarReset)
ON_REGISTERED_MESSAGE(AFX_WM_TOOLBARMENU, OnToolbarContextMenu)
ON_COMMAND(ID_VIEW_OUTLOOKBAR, OnViewOutlookBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_OUTLOOKBAR, OnUpdateViewOutlookBar)
ON_COMMAND_RANGE(ID_SHORTCUT_1, ID_SHORTCUT_4, OnOutlookBarShortcut)// , ID
ON_UPDATE_COMMAND_UI_RANGE(ID_SHORTCUT_1, ID_SHORTCUT_4, OnUpdateOutlookBarShortcut)
ON_COMMAND(ID_VIEW_CAPTIONBAR, OnViewCaptionBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_CAPTIONBAR, OnUpdateViewCaptionBar)
ON_COMMAND_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnAppLook)
ON_UPDATE_COMMAND_UI_RANGE(ID_VIEW_APPLOOK_2000, ID_VIEW_APPLOOK_2007_4, OnUpdateAppLook)
END_MESSAGE_MAP()
CMainFrame 의 OnOutlook BarShortcut 에서void CMainFrame::OnOutlookBarShortcut(UINT id)
{
const int nIndex = id - ID_SHORTCUT_1;// 。 ID 。
ASSERT( nIndex >=0 && nIndex < NUMVIEWS );
if ( nIndex < 0 || nIndex >= NUMVIEWS )
return;
if (!m_pViews)
return;
CView* pNewView = m_pViews[nIndex];
if (!pNewView)
return;
CView* pActiveView =GetActiveView();
if ( !pActiveView ) // No currently active view
return;
if ( pNewView == pActiveView ) // Already there
return;
m_nCurView = nIndex; // Store the new current view's index
// exchange view window ID's so RecalcLayout() works
UINT temp = ::GetWindowLong(pActiveView->m_hWnd, GWL_ID);
::SetWindowLong(pActiveView->m_hWnd, GWL_ID,::GetWindowLong(pNewView->m_hWnd, GWL_ID));
::SetWindowLong(pNewView->m_hWnd, GWL_ID, temp);
// Display and update the new current view - hide the old one
pActiveView->ShowWindow(SW_HIDE);
pNewView->ShowWindow(SW_SHOW);
SetActiveView(pNewView);
RecalcLayout();
pNewView->Invalidate();
// , 。
CString strCaption;
strCaption.Format (_T("View %d"), nIndex + 1);
m_wndCaptionBar.SetText (strCaption);
m_wndCaptionBar.RedrawWindow ();
}
대체로 이렇다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
vs2010 명령줄에서 msbuild로 웹 사이트 발표먼저 원래 vs 2008 코드를 보도록 하겠습니다. vs2010 코드 다시 봐요. 차이점: 1.msbuild은 4.0의 2.원래의CopyWebApplication은 지원되지 않으며 입니다.WPPCopyWebAppli...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.