Click here to Skip to main content
15,881,248 members
Articles / Mobile Apps

Creating MDI programs with eVC++ 3.0

Rate me:
Please Sign up or sign in to vote.
3.17/5 (6 votes)
4 Jul 2003CPOL2 min read 59K   274   16   3
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)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionradio selection or text box leaves view unaltered Pin
mohitaren3-Mar-06 23:33
mohitaren3-Mar-06 23:33 
Generaldestroy all hide windows Pin
flagship_tr2-Sep-05 6:39
flagship_tr2-Sep-05 6:39 
Generali cant download this zip file(65k) Pin
hooshang Karami24-Aug-03 0:56
hooshang Karami24-Aug-03 0:56 

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

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