Creating a Mini Frame-Based Application

 

Overview

This topic shows how to create a mini frame, as opposed to a full main frame, based application

Prerequisites:

A mini frame is frame window with tool window type of title based. Although it is usually used as an addition to a full frame window, you can still create an application whose main or primary object is a mini frame.

Creating the Application

The mini frame window is based on the CMiniFrameWnd class. If you want to create an application based on it, don't use the application wizard. For one thing the job involved in modifying the application can be overwhelming and uselessly difficult. For another, it is particularly easy to create a mini frame-based application. What you have to do is to call and retrieve the return value of the AfxRegisterWndClass() global function, declare a variable or a pointer to CMiniFrameWnd, pass it to the CMiniFrameWnd::Create() method, and finally initialize the application's m_pMainWnd variable.

Practical Learning: Starting the Exercise

  1. Start Microsoft Visual C++ and create a Win32 Application or Project named ExoMini1
  2. Create it as an Empty Project
  3. Access the project settings or properties settings and choose to Use MFC In A Shared DLL
  4. Add a new C++ Source File and name it Exercise
  5. In the empty file, type the following:
     
    #include <afxwin.h>
    
    class CExerciseApp : public CWinApp
    {
    public:
    	BOOL InitInstance();
    };
    
    BOOL CExerciseApp::InitInstance()
    {
        CMiniFrameWnd *MiniApp = new CMiniFrameWnd();
    
        CString StrClassName = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | 
    						CS_DBLCLKS,
    				              LoadCursor(IDC_ARROW),
    			                      (HBRUSH)GetSysColorBrush(
    							COLOR_BTNFACE),
    	                                       LoadIcon(IDI_APPLICATION));
    
        MiniApp->Create(StrClassName, "The Fundamentals of MFC",
    		WS_POPUP | WS_CAPTION | WS_SYSMENU |
    		MFS_MOVEFRAME | MFS_THICKFRAME,
    		CRect(120, 100, 560, 380));
    
        m_pMainWnd = MiniApp;
        m_pMainWnd->ShowWindow(SW_SHOWNORMAL);
        m_pMainWnd->UpdateWindow();
    
        return TRUE;
    }
    
    CExerciseApp theApp;
  6. Test the application
  7. After using it, close it and return to your programming environment

 

 
 

Home Copyright © 2003-2007 FunctionX, Inc. FunctionX