Stingray Studio : Getting Started Guide : Chapter 6 Support for the MFC Feature Pack : Migrating a New Stingray Studio Application to Use the FoundationEx Library
Migrating a New Stingray Studio Application to Use the FoundationEx Library
Migrating Traditional MFC (non-MFC Feature Pack) Applications to Use the FoundationEx library
This section demonstrates how to add FoundationEx classes to a skeleton MFC application that has not had any new MFC features added.
File > New > Project
Create a new MFC Project by selecting the MFC Application option. Give it a name and location and click OK.
Select MFC Standard Project Type
In the ‘Application Type’ section of the MFC Application Wizard, select ‘MFC Standard’ from the ‘Project Type’ selection.
Select Menu and Toolbar
In the ‘User Interface Features’ section of the MFC Application Wizard, select the ‘Use MenuBar and ToolBar’ option.
Finish the Application Wizard
Finish selecting any other options and click ‘Finish.’ A skeleton MFC application will then be created.
Replace CWinApp with SFLWinAppEx
All new application framework features start with the SFLWinAppEx class. Replace all instances of CWinApp with SFLWinAppEx, including any global scope instances that use the :: operator.
Replace CFrameWnd or CMDIFrameWnd with SFLFrameWndEx or SFLMDIFrameWndEx Respectively
Replace Single Document Interface frame instances of CFrameWnd with SFLFrameWndEx, including any global scope instances using ::. Replace Multiple Document Interface frame instances of CMDIFrameWnd with SFLMDIFrameWndEx, including any global scope instances that use the :: operator.
Replace CMDIChildWnd with SFLMDIChildWndEx
For Multiple Document Interface applications, replace all instances of CMDIChildWnd classes with SFLMDIChildWndEx, including any global scope instances that use the :: operator.
Replace CControlBar with SFLDockablePaneEx
For docking window functionality, replace all instances of CControlBar with SFLDockablePaneEx. Also, Replace instances of DockControlBar() in your frame classes with DockPane().
Unicode Build Configurations
By default, skeleton MFC applications are set to use Unicode as the character set. If you do not wish to use a Unicode version of the FoundationEx library, you will need to change this in the application’s project settings.
Add a MenuBar
By default, SDI and MDI, applications are expected to have at least one MenuBar associated with the application frame. For applications without a menu, refer to the Tips and Troubleshooting section.
MainFrm.h
 
SFLMenuBarEx m_wndMenuBar;
MainFrm.cpp
 
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//..
if(!m_wndMenuBar.Create(this))
{
TRACE(“Failed to create Menu.\n”);
return -1;
}
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() |
CBRS_SIZE_DYNAMIC);
CMFCPopupMenu::SetForceMenuFocus(FALSE);
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
DockPane(&m_wndMenuBar, AFX_IDW_DOCKBAR_TOP);
//..
}
Migrating an MFC Feature Pack-based Application to Use the FoundationEx Library
This section demonstrates how to add FoundationEx classes to an MFC application that has MFC Feature Pack features already added to it.
NOTE >> We recommend that if you are going to use the FoundationEx library you migrate from an existing Stingray application or you do so from a skeleton application. Generating an MFC Feature Pack application with MFC Feature Pack features generates a tremendous amount of code that will need to be removed or reorganized. Thus, it is easier to avoid this step, if possible. We do recommend, however, that you generate an MFC Feature Pack application with MFC Feature Pack features if you wish to study how the base MFC classes are used to handle the new RibbonBar, ToolBar, and so on.
Replace CWinAppEx with SFLWinAppEx
All new application framework features start with the SFLWinAppEx class. Replace all instances of CWinAppEx with SFLWinAppEx, including any global scope instances that use the :: operator.
Replace CFrameWndEx or CMDIFrameWndEx with SFLFrameWndEx or SFLMDIFrameWndEx Respectively
Replace Single Document Interface frame instances of CFrameWndEx with SFLFrameWndEx, including any global scope instances that use the :: operator. Replace Multiple Document Interface frame instances of CMDIFrameWndEx with SFLMDIFrameWndEx, including any global scope instances that use the :: operator.
Replace CMDIChildWndEx with SFLMDIChildWndEx
For Multiple Document Interface applications, replace all instances of CMDIChildWndEx classes with SFLMDIChildWndEx, including any global scope instances that use the :: operator.
Replace CDockablePane with SFLDockablePaneEx
For docking window functionality, replace all instances of CDockablePane with SFLDockablePaneEx. Also, Replace instances of DockControlBar() in your frame classes with DockPane().
Unicode build configurations
By default, MFC Feature Pack applications are set to use Unicode as the character set. If you do not wish to use a Unicode version of the FoundationEx library, you will need to change this in the application’s project settings.
Replace CMFCToolBar with SFLMenuBarEx
By default, SDI and MDI, applications are expected to have at least one MenuBar associated with the application frame. Replace CMFCToolBar with SFLToolBarEx and CMFCMenuBar with SFLMenuBarEx. For applications without a menu, refer to the Tips and Troubleshooting section.
NOTE >> Previously, some frame classes provided a member menubar. This is no longer the case. If a menubar is not present, one should be created. Refer to the Tips and Troubleshooting section for information on applications that do not have a menubar.
Replacing the Application Look and Feel
The application look and feel sections that are generated by the Microsoft application wizards can be removed, since look and feel is handled in the base frame classes in conjunction with the SFLAppStyleEx class.