A Tool Bar

Source: Internet
Author: User

 

Tool bar is also a common control.The CToolBar class is used in MFC to encapsulate various operations of toolbar controls. By calling
BOOL Create (CWnd * pParentWnd, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP, UINT nID = AFX_IDW_TOOLBAR); Create a window using the following special style of toolbar controls:

  • CBRS_TOPThe toolbar is at the top of the parent window.
  • TCBRS_BOTTOMThe toolbar is at the bottom of the parent window.
  • CBRS_FLOATINGTool bar is floating

To create a toolbar, follow these steps:Create a window, and then use BOOL LoadToolBar (LPCTSTR lpszResourceName); load the toolbar directly from the resource, or load the bitmap and specify the ID of each button. The Code is as follows:

UINT uID [5] = {IDM_1, IDM_2, IDM_3, IDM_4, IDM_5 };
  
M_toolbar.Create (pParentWnd );
  
M_toolbar.LoadBitmap (IDB_TOOLBAR );
  
M_toolbar.SetSizes (CSize (20, 20), CSize (16, 16); // you can specify the large size of a button.
  
And the size of the bitmap on the button
   
M_toolbar.SetButtons (uID, 5 );
  

AppWizard also generates tool bar code when generating code, and supports the dock function. Therefore, you do not need to directly operate the toolbar object.

The messages sent to the parent window when the buttons on the toolbar are pressed are the same as those in the menu, so you can useThe ON_COMMAND macro maps rows. Likewise, the buttons in the toolbar support ON_UPDATE_COMMAND_UI operations, such as SetCheck and Enable. You can use the buttons as a menu item with the same ID.

In subsequent chapters4. D. Use AppWizard to create and use the ToolBar StatusBar Dialog Bar.

 

Related Article

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.