WTL MDI Support Class for WinCE

WTL is a very useful template library for Windows programming, especially for Pocket PC and SmartPhone (which do not even support MFC). But, when I implement a multiview application on SmartPhone and Pocket PC, a block occurred. WTL cannot create a MDI project in WinCE. And, I tried to port a MDI project on the desktop; unfortunately, I failed. So, I decided to create a MDI support class myself, god bless me. It is not such difficult as what I thought initailly.

I created a template class named CMDIBase. You can inherit it from your MainFrame class, like this:

#include "MDIBase.h"

class CMainFrame : public CFrameWindowImpl<CMainFrame>,
                   public CUpdateUI<CMainFrame>,
                   public CMessageFilter,
                   public CIdleHandler,CMDIBase<CMainFrame>

then and a msg chain in CMainFrame's message map:

CHAIN_MSG_MAP(CMDIBase<CMainFrame>)

and used functions in CMDIBase:

InitailToolBar
SwitchView
EnableUIItem

The description is below. It also was written in the CMDIBase code file.

Description

This class is a WTL-based template class, and only for WinCE because it is not so useful if you can create a WTL MDI project on the desktop.

Note: CMDIBase must be used in a SDI WTL project.

The motivation of making this class is to add Multiple view UI support for WinCE WTL-based project.

It provides some functions for changing the view and menubar or toolbar related to the view. You can update the status of a command item in the menubar or toolbar. The most important thing is that it provides a more reasonable way to handle messages in the right place. It's just like in an MFC MDI project; you can handle menu commands in the related view class, not like in a WTL MDI project, where you can hardly chain a message into a view and all command messages must be handled by the mainframe.

The following list shows the main functions in CMDIBase:

  • InitailToolBar: It just called a create toolbar function and a movewindow function. If it does not call movewindow, the mainframe cannot be displayed correctly.
  • SwitchView: Switches to the view you want to show, and loads the related menu and toolbar. menuID and toolbarID must be uniform.
  • EnableUIItem: Set the menu item and toolbar item to enable/disable.

CUIUpdate class does not work for these, but it can set the check state correctly. So, the setcheckstatus function is not added in CMDIBase.



About the Author

ff tongzhi

lost my way

Downloads

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Live Event Date: December 18, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this upcoming webcast …

Most Popular Programming Stories

More for Developers

RSS Feeds