Professional UI Solutions
Site Map   /  Register
 
 
 

Command Manager

How can I get the version of Prof-UIS at run time?

The following two methods of the command manager allow you to retrieve which version of Prof-UIS you are using:

DWORD dwVersion = g_CmdManager.GetVersionDWORD();

CString sVersion = g_CmdManager.GetVersionString();

What is the command manager?

When running Prof-UIS applications, you may have noticed that some commands in pop-up menus are associated with icons. If such a command in a pop-up menu is also associated with a button in a toolbar, the very same icon is displayed for this toolbar button. This feature is automatically provided by the command manager, which is an object of the CExtCmdManager type and can be accessed from within the entire application with the g_CmdManager smart pointer.

The most important role of the command manager is to keep descriptions of the commands available in the application. Each command description is a CExtCmdItem object that keeps information about a particular command. This information includes:

  • command identifier
  • menu text, which is used when the command is associated with a menu item
  • toolbar text, which is used when the command is fired with a toolbar button
  • tooltip text
  • text that is displayed in the status pane
  • icon
  • command usage statistics required for supporting expanded pop-up menus

The command manager is a named collection of command profiles. Each profile is an object of the CExtCmdProfile class and has its own unique name and keeps a list of HWND handles. This allows any window of the application to "know" which profile it belongs to. Although the command manager features multiple profile support, in most cases, applications are based on a single profile. This profile keeps HWND of the main frame window or main dialog, which allows, the main window and all its child controls to find a required command description automatically.

When starting up the application, you should initialize the command manager. Add your command profile to the command manager and then add all command descriptions to this profile. You can do this at the beginning of the OnCreate() method of the main frame window or in the OnInitDialog() of the main dialog window:

VERIFY(
    g_CmdManager->ProfileSetup(
        "name of the command profile",
        GetSafeHwnd() // HWND of the frame window
        )
    );
The easiest way to populate the command manager with the commands you need in the application, is to register your menu bar and/or toolbar resources in it:
VERIFY(
    g_CmdManager->UpdateFromMenu(
        "name of the command profile",
        IDR_MAINFRAME
        )
    );
VERIFY(
    g_CmdManager->UpdateFromMenu(
        "name of the command profile",
        IDR_YourMdiProjectsDOCTYPE
        )
    );
VERIFY(
    g_CmdManager->UpdateFromToolBar(
        "name of the command profile",
        IDR_TOOLBAR1
        )
    );
Finally, you need to notify the command manager about destroying the frame window in CMainFrame::DestroyWindow() (or in the methods OnOK() and OnCancel() of the main dialog window) so that it can release HWND of the window:
g_CmdManager->ProfileWndRemove( GetSafeHwnd() );
This is critical for applications supporting Automation.

How to add/remove a command profile to/from the command manager?

Since Prof-UIS supports multiple profiles, you can add a new profile with the ProfileSetup method:
g_CmdManager->ProfileSetup( _T( "ProfileSectionName" ), hWnd );
Any profile can be removed by using this code:
g_CmdManager->ProfileDestroy( _T( "ProfileSectionName" ));

If you have any questions, please visit our forum or contact our technical support team at support@prof-uis.com.