MFC-interface library BCG User Guide

Source: Internet
Author: User

(Abstract)  

This document uses the MDI application as an example to describe how to use the BCG interface library in the existing VC ++ project. My development environment is vs2003.

1. Add the BCG/bcgcbpro directory path to "project properties-> C/C ++-> General-> Add include directory, add the BCG/bin directory path to "project properties-> linker-> General-> additional library directory.

2. Make sure that afxoleinit () is called in the initinstance () member function of the cwinapp derived class (set as cmyapp ();

3. Add the following in the exitinstance () function:

     Cleanstate ();
     Bcgcbprocleanup ();

4. Add it in stdafx. h.

 # Include "BCG/bcgcbproinc. H"

5. Add a base class for the cmyapp as follows:

 Class cmyapp: Public cwinapp, public cbcgpworkspace

6. Set the storage location of personalized data in the Registry and the features that require personalization. In the cmyapp: initinstance () function, add:

  Setregistrybase (_ T ("Settings "));

  Initmousemanager ();
 Initcontextmenumanager ();
 Initkeyboardmanager ();

7. SetChange cmdiframewnd to cbcgpmdiframewnd. Note that all cmdiframewnd in mainfrm. h and mainfrm. cpp must be changed.

8. Change cmdichildwnd to cbcgpmdichildwnd,. H, and. cpp.

9.Ctoolbar    Change m_wndtoolbar to cbcgptoolbar m_wndtoolbar, and add a cbcgpmenubar member m_wndmenubar to your cmainframe class, as shown below:

   Cbcgpmenubar  M_wndmenubar;   // New menu bar
  Cbcgptoolbar    M_wndtoolbar;    // Application Toolbar

10. To make the menu bar take effect and dock, add the following content to the cmainframe: oncreate () function:

   If (! M_wndmenubar.create (this )){
    Trace0 ("failed to create menubar \ n ");
    Return-1;    // Fail to create
  }

    M_wndmenubar.setbarstyle (m_wndmenubar.getbarstyle () |
                            Cbrs_tooltips | cbrs_flyby |

                           Cbrs_size_dynamic );

    M_wndmenubar.enabledocking (cbrs_align_any );
  Dockcontrolbar (& m_wndmenubar );

Note: You can use multiple cbcgptoolbar in your application. Their corresponding bitmaps are automatically merged into one bitmap. However, you can only use one cbcgpmenubar object.

   At this point, the basic settings have been completed, and your program should be able to compile and run normally. The following describes how to set different styles for applications.

1. Add a pop-up menu on the menu bar and add a menu item. The text above is "Office 2003", "Office 2007 (blue )", "Office 2007 (black)", "Office 2007 (silver)", "Office 2007 (Aqua)", the corresponding menu item IDs are id_view_applook_2003, id_view_applook_2007_1, id_view_applook_2007_2, large, id_view_applook_2007_4.

2. Add a message response for these five menus:

  In the mainfrm. cpp file, add message ing (between begin_message_map and end_message_map ):

  On_command_range (id_view_applook_2003, id_view_applook_2007_4, onapplook)

  Add the onapplook function declaration to the cmainframe class:

  Afx_msg void onapplook (uint ID );

  Add the method implementation:

  Void cmainframe: onapplook (uint ID ){
       Cwaitcursor wait;

         Cbcgpvisualmanager2007: setcustomcolor (colorref)-1 );

        Switch (ID ){
             Case id_view_applook_2003: cbcgpvisualmanager: setdefaultmanager (

                                        Runtime_class (cbcgpvisualmanager2003 ));
                                      Break;

               Case id_view_applook_2007_1:

                       Cbcgpvisualmanager2007: setstyle (cbcgpvisualmanager2007: vs2007_aqua );

                      Cbcgpvisualmanager: setdefamanager Manager (
                       Runtime_class (cbcgpvisualmanager2007 ));

                      Break; 

              ...

         }
         Redrawwindow (null, null, rdw_allchildren | rdw_invalidate | rdw_updatenow |                    Rdw_frame | rdw_erase );

      }

   In Office 2007, other style switches are similar to id_view_applook_2007_1, Which is omitted here.

3. During running, make sure that the program can find the relevant DLL under the bin directory; otherwise, the switch style will fail.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.