Click here to Skip to main content
Click here to Skip to main content

Creating MDI programs with eVC++ 3.0

, 4 Jul 2003 CPOL
Rate this:
Please Sign up or sign in to vote.
An article to illustrate how to create multiple views in WinCE using eVC++ 3.0 compiler for PocketPC 2002

Sample Image - MDIWinCE.jpg

Introduction

WinCE for PocketPC 2002 normally only supports SDI MFC applications. With a little trickery, you can convert it to an MDI application by swapping views when necessary. You still will not be able to see more than one view at a time due to limited real-estate. You have the choice of just hiding the current view, destroying the current view or hide some and destroy others. New views are created dynamically and there is no limit to the number of views that can be in memory at any one time -- except of course the limit will be the amount of memory in the hardware. The views can be any type supported by the eVC++ 3.0 compiler.

There can be as many different view classes as desired, but only one instance of any given view. So you can have one instance of each of these views: CMyFirstView, CMySecondView and CMyThirdView, but you can not have two instances of CMyFirstView. The reason is because OnSelectNextView() searches its list of current views to see if a view of the desired class already exists. If it does exist, then it is activated. Otherwise, if it does not exist a new instance of the desired class type is created and added to the list.

Using the code

These are the steps needed to implement the class in your project.

  1. Create a new MFC Document/View project, or use an existing project.
  2. Copy the two files SVMainFrame.cpp and SVMainFrame.h into the project directory and add them to the project.
  3. Open CMainFrm.h and replace CFrameWnd with CSFMainFrame.
class CMainFrame : public CSVMainFrame
{
  // class definition here.
{
  1. In CMainFrm.h DELETE the CCeCommandBar m_wndCommandBar object because it is declared in CSVMainFrame.h.
  2. In CMainFrm.cpp, replace both occurrences of CMainWnd with CSVMainFrame. That class occurs twice in the file.
  3. Create as many views as necessary, adding navigational buttons or menu items to allow the user to move forward or backwards through the list of views. If you create CFormView classes, make sure the style to Child and Border to None.
  4. To move forward in a chain of views, call the OnSelectNextView() method as shown below. In this example, m_selection is a radio button where 0 means to hide the window and non-0 is destroy the current window:
void CSelViewDemoView::OnNextViewButton() 
{
    UpdateData();
    CMainFrame* pMFrame = (CMainFrame*)GetParentFrame();
    pMFrame->OnSelectNextView(RUNTIME_CLASS(CMySecondView), 
                m_selection == 0 ? AIT_HIDE_WINDOW : AIT_DESTROY_WINDOW);
}
  1. To navigate backward in the chain of view, call OnSelectPrevView(). In this example, m_selection means the same as in the previous example. If there is no previous view, then the current view does not change.
void CMySecondView::OnPreviousView() 
{
     UpdateData();
     CMainFrame* pMFrame = (CMainFrame*)GetParentFrame();
     pMFrame->OnSelectPrevView(m_selection == 0 ? AIT_HIDE_WINDOW : 
                                                  AIT_DESTROY_WINDOW);
    
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Stober
Web Developer
United States United States
No Biography provided

Comments and Discussions

 
Questionradio selection or text box leaves view unaltered Pinmembermohitaren4-Mar-06 0:33 
Generaldestroy all hide windows Pinmemberflagship_tr2-Sep-05 7:39 
Generali cant download this zip file(65k) Pinmemberhooshang24-Aug-03 1:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150414.1 | Last Updated 5 Jul 2003
Article Copyright 2003 by Stober
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid