views:

48

answers:

0

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?