Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WTL

SoftG Application Framework 1.62

4.00/5 (5 votes)
13 May 2009MPL3 min read 29.4K   404  
Automation framework application development, realize the software functions and software frame separation. Support plug-in support theme

Introduction

The core technology is based on Microsoft COM technology.

Simple Introduction

  1. New software, software function and design of software frame separation
  2. The COM technology + WTL design
  3. Automation framework application development, support, support macros language development
  4. Support plug-in design
  5. 32 and 64-bit versions
  6. Support can be defined theme, theme
  7. Built-in multinational language pack, including language switch
  8. The UNICODE programming
  9. The built-in ChengRong application framework "wizard, can generate MFC ATL WTL project applications
  10. The automatic preservation window coordinates etc. function

Main Frame

An application can have multiple main frames. Each main frame can be a single document, single document window lattice, document portion, document window lattice, points. The framework has ordered the collection, the menu bar and the commands, composed, also can add points window or grid page document. The main frame is set IMainFrames unified management.
Main frame window coordinates automatic memory.

The ChengRong application framework of application management interface:
IArtApp interface is the ChengRong application framework of managers, and is the first program execution prior to creating the interface. If you fail to create the ChengRong application framework, it will not work properly.

The Collection Order

The collection ICommandBars interface command. There is IMenuBar menu bar and the commands ICommandBar composition. Command the sidebar, is also called the command here. Food has become a menu commands ICommandBar bar, a menu item and ordered the button, collectively known as a command interface name is ICommandItem: ICommandItem interface with a user can change orders.

Command Processor

Command processor INotifyCommand interface, user interface to handle INotifyCommand must realize the main frame, orders, the menu bar, a pop-up menu commands.
The main frame, orders, and ordered a command INotifyCommand can have the interface.

Command Processor Set

Command processor INotifyCommands interface is used to manage all the command processors. The main frame, the collection INotifyCommands interface with orders.

User

  1. Download SetupSoftGFramework.exe
  2. Setup...
  3. Regsvr Type library

    Regsvr.jpg

  4. Setup Wizard to Visual Studio 2005 or Visual Studio 2008.

    Setup_Wiard.jpg

  5. Run Visual Studio 2005 or Visual Studio 2008.
  6. Add "SoftG Frame\Include" to "Tools\Options\Projects and Solutions\VC++ Directories"
  7. New Project
  8. Click "SoftG Frame"\"MFC Application". Input the item name "MyProject." Click OK.
  9. According to guide project:

    ApplicationSettings.jpg

    GeneratedClass.jpg

    Language.jpg

  10. Project Info.

    MyProject.jpg

File nameDescription
MainCommand.cpp or MainCommand.h

The new command processing mode.

C++
class CMainCommand :
public art::CNotifyCommandImpl<CMainCommand>
{
public:
void OnHelp(UINT nCmdID, art::ICommandItem *pCmdUI);
MyProject.cpp or MyProject.h

CMyProjectApp class. Added "Art::CArtApp" base class.

C++
class CMyProjectApp : public CWinApp,
public art::CArtApp
{
MyProjectDoc.cpp or MyProjectDoc.h

CMyProjectDoc. No changes

C++
class CMyProjectDoc : public CDocument
{
MyProjectView.cpp or MyProjectview.h

CMyProjectView class. Added "art::CDataViewImpl<CMyProjectView>" base
classes

C++
class CMyProjectView :
public CView,
public art::CDataViewImpl<CMyProjectView>
{

Using the Code

  1. Initialize "ChengRong application framework" environment:
    C++
    HRESULT hr = art::CArtApp::InitArtApp();  //Init IArtApp Interface.
  2. Create main frame:

    Call IArtApp interface CreateMainFrame method of main frame, and create IMainFrame returns to the main frame adds interfaces, command processor INotifyCommand interface.
    Through the IMainFrame interface put_SDIDataView attribute, add data views.

    C++
    bool CMyProjectApp::CreateSDIWindow()
    {
    CMainCommand mc;
     HRESULT   hr = S_FALSE;
     HICON hIcon  = (HICON)::LoadImage(AfxGetResourceHandle(),
          MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
     HMENU hMenu = ::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));
     hr = GetArtApp()->CreateMainFrame(art::artMainFrameTypeSDI,
          (wireHMENU)hMenu, (long)hIcon, L"Window Name", &m_pMainFrame);
     if (S_OK == hr)
     {
      m_pMainFrame->AddNotifyCommand((art::INotifyCommand*)&mc);
      GetArtApp()->put_AppName(L"Software Name");
    
      CreateTools();
    
      CMyProjectView *pDocView = NULL;
      pDocView = new CMyProjectView();
      m_pMainFrame->put_SDIDataView((art::IDataView*)pDocView);
    
      m_pMainFrame->ShowWindow(SW_SHOW);
      GetArtApp()->Run();
      return true;
     }
     return false;
    } 
  3. Create CommandBar:

    Create a command button with three:

    C++
    void CMyProjectApp::CreateTools()
    {
        ATLASSERT(NULL != m_pMainFrame);
    
        CComPtr<:icommandbars>    pCommandBars;
        CComPtr<:icommandbar>    pCommandBar;
        CComBSTR            bstrTitile;
    
    #pragma warning(disable:4309)
    #pragma warning(disable:4305)
        TBBUTTON tbAdd[] = {
            {0, ID_FILE_NEW,    TBSTATE_ENABLED,
    	TBSTYLE_BUTTON|TBSTYLE_TOOLTIPS, 0L, ID_FILE_NEW},
            {0, 0,                0,                 TBSTYLE_SEP,    0L, 0},
            {1, ID_FILE_CLOSE,    TBSTATE_ENABLED,
    	TBSTYLE_BUTTON|TBSTYLE_TOOLTIPS, 0L, ID_FILE_CLOSE},
            {0, 0,                0,                 TBSTYLE_SEP,    0L, 0},
            {2, ID_HELP,        TBSTATE_ENABLED,
    	TBSTYLE_BUTTON|TBSTYLE_TOOLTIPS, 0L, ID_HELP},
        };
    #pragma warning(default:4309)
    #pragma warning(default:4305)
    
        m_pMainFrame->get_CommandBars(&pCommandBars);
    
        bstrTitile = L"Standard";
        pCommandBars->AddCommandBar(bstrTitile, 1, 16, 16, &pCommandBar);
        pCommandBar->InsertCommand(0, sizeof(tbAdd)/sizeof(tbAdd[0]), (BYTE*)&tbAdd);
        pCommandBar->SetImageList((long)AfxGetResourceHandle(),
    	16, 16, MAKEINTRESOURCEW(IDR_MAINFRAME));
    }
  4. Command processing:

    Command received INotifyCommand interface. The user must realize INotifyCommand, according to the method of filling:

    MethodsDescription
    C++
    QueryState(UINT nCmdID,
    ICommandItem *pCmdUI);
    query State
    C++
    NotifyCommand(UINT codeNotify,
    int nCmdID, ICommandItem *pCmdUI);
    C++
    NotifyCommandPoint(UINT nCmdID, POINT *pt,
    ICommandItem *pCmdUI, IDispatch *ppmb);
    C++
    GetCommandTips(UINT nCmdID, BSTR *bstrTips);
    The standard with full screen with methods.
    Get orders a hint.
    C++
    STDMETHODIMP ExpansionCommand
    (UINT nCmdID, ICommandItem *pCmdUI);
    When the call out commands.

  5. ICommandItem interface:
    C++
    virtual HRESULT __stdcall get_Caption (BSTR * pVal );
    virtual HRESULT __stdcall put_Caption (BSTR pVal );
    virtual HRESULT __stdcall get_Enable (VARIANT_BOOL * pVal );
    virtual HRESULT __stdcall put_Enable (VARIANT_BOOL pVal );
    virtual HRESULT __stdcall get_Check (VARIANT_BOOL * pVal );
    virtual HRESULT __stdcall put_Check (VARIANT_BOOL pVal );
    virtual HRESULT __stdcall get_Radio (VARIANT_BOOL * pVal );
    virtual HRESULT __stdcall put_Radio (VARIANT_BOOL pVal );
    virtual HRESULT __stdcall get_Visible (VARIANT_BOOL * pVal );
    virtual HRESULT __stdcall put_Visible (VARIANT_BOOL pVal );
    virtual HRESULT __stdcall get_Cmd (unsigned long * nCmdID );
    virtual HRESULT __stdcall put_Cmd (unsigned long nCmdID );
    virtual HRESULT __stdcall get_index (unsigned long * nIndex );
    virtual HRESULT __stdcall get_CommandItemType (enum artCommandItemType * pVal );
    virtual HRESULT __stdcall put_CommandItemType (enum artCommandItemType pVal );
    virtual HRESULT __stdcall get_Width (long * pVal );
    virtual HRESULT __stdcall put_Width (long pVal );
    virtual HRESULT __stdcall get_NotifyCommand (IDispatch * * pNotifyCommand );
    virtual HRESULT __stdcall put_NotifyCommand (IDispatch * pNotifyCommand );
    virtual HRESULT __stdcall get_ItemWindow (wireHWND * phwnd );
    virtual HRESULT __stdcall get_CmdHandle (VARIANT_BOOL * pHandle );
    virtual HRESULT __stdcall put_CmdHandle (VARIANT_BOOL pHandle );
    virtual HRESULT __stdcall get_IconIndex (unsigned long * nIndex );
    virtual HRESULT __stdcall put_IconIndex (unsigned long nIndex );
    virtual HRESULT __stdcall get_Icon (wireHICON * hIcon );
    virtual HRESULT __stdcall put_Icon (wireHICON hIcon );
    virtual HRESULT __stdcall get_Bitmap (wireHBITMAP * hBitmap );
    virtual HRESULT __stdcall put_Bitmap (wireHBITMAP hBitmap );
    virtual HRESULT __stdcall get_ChildCommandBar (ICommandBar * * pCommandBars );
    virtual HRESULT __stdcall put_ChildCommandBar (ICommandBar * pCommandBars );
    virtual HRESULT __stdcall get_ParentCommandBar (ICommandBar * * pCommandBars );
    virtual HRESULT __stdcall IsChildItem (VARIANT_BOOL * pChild );
    virtual HRESULT __stdcall CreateCommandBar (ICommandBar * * pCommandBars );
    virtual HRESULT __stdcall MoveItem (unsigned long nNewIndex );

History

  • 13th May, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Mozilla Public License 1.1 (MPL 1.1)