1

複数 (実際には 3 ) のビューを SDI アプリケーションに追加し、ユーザーが自分の選択に応じてビューが読み込まれるかどうかを選択できるようにしようとしています。

画像

MS の公式ドキュメントのこのチュートリアルに従いました。したがって、CAdminView、CAssistantView、CBiblioView、およびダイアログ フレームに関連付けられた認証クラスの 3 つのクラスを作成しました。

私の質問は:

1) この 3 つのビュー クラスを (グラフィカルに) 編集する方法

2) 最初は認証ダイアログ ウィンドウだけを表示したいのですが、どうすればよいですか?

* I tried to change m_pMainWnd->ShowWindow(SW_SHOW);

  by m_pMainWnd->ShowWindow(SW_HIDE); but no expected result

3) パラメータに従ってビューをロードすることを期待しています。これは、InitInstance 関数に追加したものです。

                CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView();
                m_BiblioView = (CView*) new CBiblioView;
                m_AdminView = (CView*) new CAdminView;
                m_AssistantView = (CView*) new CAssistantView;
                CDocument* pCurrentDoc = ((CFrameWnd*)m_pMainWnd)->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;

                // The ID of the initial active view is AFX_IDW_PANE_FIRST.
                // Incrementing this value by one for additional views works
                // in the standard document/view case but the technique cannot
                // be extended for the CSplitterWnd case.
                UINT viewID = AFX_IDW_PANE_FIRST + 1;
                CRect rect(0, 0, 0, 0); // Gets resized later.

                // 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_AdminView->Create(NULL, "Fenetre Administrarteur", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
                m_AssistantView->Create(NULL, "Fenetre Assistant", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
                m_BiblioView->Create(NULL, "Fenetre Bibliothecaire ", WS_CHILD, rect, m_pMainWnd, viewID, &newContext);
                // 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_AdminView->SendMessage(WM_INITIALUPDATE, 0, 0);
                m_AssistantView->SendMessage(WM_INITIALUPDATE, 0, 0);
                m_BiblioView->SendMessage(WM_INITIALUPDATE, 0, 0);

これは私のスイッチ機能です:

CView* CMiniProjetApp::SwitchView(int Code ) //1 : Admi / 2 : Biblio / 3 : Assistant
{
   CView* pActiveView =((CFrameWnd*) m_pMainWnd)->GetActiveView();

   CView* pNewView= NULL;
   switch(Code){

   case 1 : pNewView= m_AdminView; break;
   case 2 : pNewView= m_BiblioView; break;
   case 3 : pNewView= m_AssistantView; break;
   }

   // Exchange view window IDs so RecalcLayout() works.
   #ifndef _WIN32
   UINT temp = ::GetWindowWord(pActiveView->m_hWnd, GWW_ID);
   ::SetWindowWord(pActiveView->m_hWnd, GWW_ID, ::GetWindowWord(pNewView->m_hWnd, GWW_ID));
   ::SetWindowWord(pNewView->m_hWnd, GWW_ID, temp);
   #else
   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);
   #endif

   pActiveView->ShowWindow(SW_HIDE);
   pNewView->ShowWindow(SW_SHOW);
   ((CFrameWnd*) m_pMainWnd)->SetActiveView(pNewView);
   ((CFrameWnd*) m_pMainWnd)->RecalcLayout();
   pNewView->Invalidate();
   return pActiveView;
}

エラー通知 ??!!

*私を助けてください !

ありがとう 。

4

1 に答える 1

0

ウィンドウの表示と非表示が正しい方法です。ただし、ビューもアクティブに設定する必要があります。この MSDN サンプルVSSWAP32には、必要な作業コードがあります。

他のビューを切り替えて非表示にするために必要なコードは、記事に示されています。

于 2013-12-08T14:08:26.360 に答える