I am using the MFC Feature pack in Visual Studio 2008. I have an edit box (CMFCRibbonEdit) in a ribbon that I would like only to contain uppercase letters. I know that I can pass ES_UPPERCASE to the "Create" method, however "Create" is called from the Ribbon itself, and not explicitly by my code.
To add the edit box to my ribbon, I call this:
CMFCRibbonPanel* pPanel = pCategoryViewer->AddPanel("Panel Title");
CMFCRibbonEdit *cEdit = new CMFCRibbonPanel( ID_MYEDITBOX, 60, "Edit Title" );
pPanel->Add( cEdit );
Based on what I read on MSDN I saw I could overload the "CreateEdit" function of CMFCRibbonEdit. I tried that, but it didn't work.
class UpperCaseRibbonEdit : public CMFCRibbonEdit
{
public:
UpperCaseRibbonEdit( UINT nID, int nWidth, LPCTSTR lpszLabel )
:CMFCRibbonEdit( nID, nWidth, lpszLabel )
{}
CMFCRibbonRichEditCtrl* CreateEdit( CWnd* pWndParent, DWORD dwEditStyle )
{
return CMFCRibbonEdit::CreateEdit( pWndParent, dwEditStyle | ES_UPPERCASE );
}
};
I also tried making this call after initializing my ribbon and its controls. This didn't work either.
HWND editHwnd = GetDlgItem( ID_MYEDITBOX )->GetSafeHwnd();
SetWindowLong(editHwnd, GWL_STYLE, (LONG)GetWindowLong(editHwnd, GWL_STYLE) | ES_UPPERCASE);
Does anyone know how I could accomplish this?
As I think you already know, CMFCRibbonEdit has inside a member variable
CMFCRibbonRichEditCtrl* m_pWndEdit;
which type that is descendant of CRichEditCtrl. So, as the page @Stanich's comment states ES_UPPERCASE is not supported for it.I guess your best option is: in your derived class you do not forget to put
ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
in the message map; and looking for the base class original code:change strText in yours to be all caps letters after the GetWindowText line.