about how the Ribbon interface modifies title property issues in MFC

Source: Internet
Author: User

Recently, in the work, encountered the need to transfer software from Chinese to English. In general, controls on the MFC interface can be resolved using SetWindowText. But for the ribbon, it often doesn't. Also from the Internet to find a lot of information, the final summary is as follows.

First on

Chinese version:

English version:

, my interface includes three types of controls in the Ribbon interface, panel,button,category.

When you need to modify from code, the code is as follows

For the category interface, modify the method to include the following code in the function that generates the interface in MAINFRM OnCreate

CMFCRibbonCategory *pcategory = m_wndribbonbar.getcategory (1);
Pcategory->setname (_t ("System"));

For the Panel interface, modify the method as follows, but pay special attention. Panel may be a problem that is not considered at design time, directly, can not be modified, only through the new sub-class to do a strong turn

Strong rotor class as below, new MFC class, continue to Mfcribbonpanel

The. h file is

#pragma once
#include "afxribbonpanel.h"

Subclass of Inheriting Ribbonpanel
Class Myribbonpanel:p ublic CMFCRibbonPanel
{
Public
Myribbonpanel (void);
~myribbonpanel (void);
void Setpanelname (CString name);
};

The. cpp file is

#include "StdAfx.h"
#include "MyRibbonPanel.h"


Myribbonpanel::myribbonpanel (void)
{
}


Myribbonpanel::~myribbonpanel (void)
{
}

void Myribbonpanel::setpanelname (CString name)
{

  To assign a name to a career here
M_strname=name;
}

Then, we load the above class in MainFrm, then, the conversion Interface name code is as follows


CMFCRibbonPanel *ppanel1 = pcategory->getpanel (0);
myribbonpanel* PMyPanel1 = (myribbonpanel*) pPanel1; //Here the object of the parent class is coerced into a subclass object, without an error, indicating that it can be converted
Pmypanel1->setpanelname (_t ("User Manage"));
CMFCRibbonPanel *ppanel2 = Pcategory->getpanel (1);
myribbonpanel* PMyPanel2 = (myribbonpanel*) ppanel2;//here to cast the object of the parent class into a subclass object, without an error, that can be converted
Pmypanel2->setpanelname (_t ("Motor Control Panel"));
CMFCRibbonPanel *ppanel3 = Pcategory->getpanel (2);
myribbonpanel* pMyPanel3 = (myribbonpanel*) ppanel3;//here to cast the object of the parent class into a subclass object, without an error, that can be converted
Pmypanel3->setpanelname (_t ("Robot Control Panel"));
CMFCRibbonPanel *ppanel4 = Pcategory->getpanel (3);
myribbonpanel* PMyPanel4 = (myribbonpanel*) ppanel4;//here to cast the object of the parent class into a subclass object, without an error, that can be converted
Pmypanel4->setpanelname (_t ("Equipment Info"));

For the button, the conversion code is as follows

cmfcribbonbutton* pribbonbtn = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (ID_TOOLS_BTN_LOGIN));
Pribbonbtn->settext (_t ("Login"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (Id_tools_btn_logoff));
Pribbonbtn->settext (_t ("Logout"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (Id_tools_btn_manager));
Pribbonbtn->settext (_t ("Edit"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (id_tools_btn_axismotion));
Pribbonbtn->settext (_t ("Axis Control"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (Id_tools_btn_iotest1));
Pribbonbtn->settext (_t ("IO CARD 1"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (Id_tools_btn_iotest2));
Pribbonbtn->settext (_t ("IO CARD 2"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (ID_TOOLS_BTN_IOTEST3));
Pribbonbtn->settext (_t ("IO CARD 3"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (ID_TOOLS_BTN_IOTEST4));
Pribbonbtn->settext (_t ("IO CARD 4"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (ID_TOOLS_BTN_IOTEST5));
Pribbonbtn->settext (_t ("IO CARD 5"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (ID_TOOLS_BTN_IOTEST6));
Pribbonbtn->settext (_t ("IO CARD 6"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (ID_TOOLS_BTN_IOTEST7));
Pribbonbtn->settext (_t ("IO CARD 7"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (ID_TOOLS_BTN_IOTEST8));
Pribbonbtn->settext (_t ("IO CARD 8"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (id_tools_btn_velocity));
Pribbonbtn->settext (_t ("Axis speed Setting"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (ID_TOOLS_BTN_ETHERNET_CL));
Pribbonbtn->settext (_t ("Ethernet Client"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (Id_tools_btn_record));
Pribbonbtn->settext (_t ("View Record");

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (Id_tools_btn_calitray));
Pribbonbtn->settext (_t ("Tray calib"));

PRIBBONBTN = Dynamic_downcast (CMFCRibbonButton, M_wndribbonbar.findbyid (id_tools_btn_traypoints));
Pribbonbtn->settext (_t ("Tray Points"));

about how the Ribbon interface modifies title property issues in MFC

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.