Skip to content

Latest commit

 

History

History
 
 

viewex

<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE
    SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"-->

<html><head><title>VIEWEX Sample: Demonstrates Multiple Views, Scroll Views, and Splitter Windows</title></head><body><h1>VIEWEX Sample: Demonstrates Multiple Views, Scroll Views, and Splitter Windows</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>The VIEWEX sample illustrates the following.  </p><ul><li><p>A static splitter window in which the order and number of panes never change and the panes are usually of different view classes.</p></li><li><p>A form view (<b>CFormView</b>) that stays synchronized with other views on the same document.</p></li><li><p>Dialog data exchange (DDX), specifically of radio group button data.</p></li></ul><p>The document in VIEWEX is simple. Its data consists of a string and its color.</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note </th></tr><tr><td><p>This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.</p></td></tr></table></div><h1 class="heading">Building and Running the Sample</h1><div id="sectionSection0" class="seeAlsoNoToggleSection"><h4 class="subHeading">To build and run the VIEWEX sample</h4><div class="subSection"><ol><li><p>Open the solution viewex.sln. </p></li><li><p>On the <b>Build</b> menu, click <b>Build</b>. </p></li><li><p>On the <b>Debug</b> menu, click <b>Start Without Debugging</b>. </p></li></ol></div><p>When you first run VIEWEX, it presents a <b>New</b> dialog box in which you select the type of document window to be illustrated:  </p><ul><li><p><b>Simple Text</b> displays the string, using the current color, centered in the window.</p></li><li><p><b>Input Form View</b> provides a form (a <b>CFormView</b>) in which you can change the string in an edit control, and change the color by selecting from a radio button group.</p></li><li><p><b>Splitter Frame</b> with both Simple Text and Input Form displays in two side-by-side panes of a splitter window. When you change the string (character by character) or color in the Input Form, the Simple Text view automatically reflects the change.</p></li><li><p><b>Three-way Splitter Frame</b> displays the Input Form view in one splitter window pane. The other pane is divided into two subpanes by a splitter bar: The upper subpane displays a Simple Text view; the lower subpane displays a Color view. The Color view simply paints itself entirely in the current color.</p></li></ul><p>You can change the string by using the edit control in the input form and by clicking <b>Change Data</b> on the <b>Edit</b> menu.</p><p>You can also view multiple documents at a time. For the sake of simplicity, however, you cannot save or reopen documents, nor can you view the same document in more than one of the above windows.</p></div><h1 class="heading">Static Splitter Window</h1><div id="sectionSection1" class="seeAlsoNoToggleSection"><p>In VIEWEX, the MDI child window creates a 1-by-2 splitter window within its client area by overriding <b>OnCreateClient</b>. In the case of the three-way splitter, VIEWEX embeds a second 2-by-1 splitter window within the right-side pane of the 1-by-2 splitter window. </p><p>VIEWEX calls <b>CSplitterWnd::CreateStatic</b> instead of <b>CSplitterWnd::Create</b> to create static splitter windows instead of dynamic splitter windows. Each pane of VIEWEX's splitter window has a different view class. VIEWEX calls <b>CSplitterWnd::CreateView</b> to specify the <b>CView</b> derived class for each pane. In the case of the first pane, VIEWEX uses the view class specific in the document template object, which is passed to <b>OnCreateClient</b> in the <b>m_pNewViewClass</b> member of the <b>CCreateContext</b>. In the case of other panes, VIEWEX specifies the <b>RUNTIME_CLASS</b> of the view.</p></div><h1 class="heading">Form View</h1><div id="sectionSection2" class="seeAlsoNoToggleSection"><p><b>CInputView</b> illustrates synchronizing a form view with other views, so when the user enters data in one of the fields, the change is immediately reflected in other views. <b>CInputView</b> accomplishes this by mapping <b>ON_EN_CHANGE</b> and <b>ON_BN_CLICKED</b> for all of its controls to a central <b>OnDataChange</b> message handler. <b>OnDataChange</b> calls <b>CView::UpdateData</b> to transfer data from the screen to the member variables of <b>CInputView</b> and then calls the document's <b>UpdateAllViews</b> to inform the other views about the change.</p></div><h1 class="heading">Dialog Data Exchange (DDX)</h1><div id="sectionSection3" class="seeAlsoNoToggleSection"><p>VIEWEX's <b>CInputView</b> illustrates dialog data exchange (DDX) of radio group button data. In Iputvw.h, note that only the first button in the radio group is mapped to the member variable <code>m_iColor</code> in <b>CInputView::DoDataExchange</b>. <code>m_iColor</code> is a zero-based ordinal value (<b>int</b>) representing which radio button is selected. </p></div><h1 class="heading">Keywords</h1><div id="sectionSection4" class="seeAlsoNoToggleSection"><p>This sample demonstrates the following keywords:</p><p>CDC::FillRect; CDialog::DoModal; CDocument::OnNewDocument; CDocument::UpdateAllViews; CFrameWnd::LoadFrame; CFrameWnd::OnCreateClient; CFrameWnd::SetActiveView; CObject::Serialize; CRect::Height; CRect::Width; CSplitterWnd::CreateStatic; CSplitterWnd::CreateView; CSplitterWnd::GetPane; CSplitterWnd::IdFromRowCol; CString::GetLength; CView::GetDocument; CView::OnActivateView; CView::OnDraw; CView::OnUpdate; CWinApp::AddDocTemplate; CWinApp::InitInstance; CWinApp::OnFileNew; CWnd::DoDataExchange; CWnd::GetClientRect; CWnd::OnMouseActivate; CWnd::ShowWindow; CWnd::UpdateData; CWnd::UpdateWindow; RGB; SetBkMode; SetTextAlign; SetTextColor; TextOut; max</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note </th></tr><tr><td><p>Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task. </p></td></tr></table></div></div></div><div id="footer"><div class="footerLine"></div>
          © Microsoft Corporation. All rights reserved.  Send <a href="mailto:DevDocs@microsoft.com?subject=Documentation Feedback :VIEWEX Sample: Demonstrates Multiple Views, Scroll Views, and Splitter Windows">comments</a> about this topic to Microsoft.
      </div></div></body></html>