Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » How to disable keyboard accelerators when CExtEdit has focus Collapse All
Subject Author Date
Richard Chaney Oct 7, 2007 - 10:13 AM

My application allows customization with unmodified keyboard accelerators, using the __ECSF_ALLOW_UNMODIFIED_ACCELERATORS flag. This is so a Photoshop style tool selector can use a single keypress to select a tool.

When a CExtEdit has focus, these keys cannot be typed into the edit, since they trigger the accelerator command.

Is there a way to stop the accelerators when CExtEdit has focus? Thanks.


Technical Support Oct 8, 2007 - 10:11 AM

You should use the following message pre-translation in your main frame class:

BOOL CMainFrame::PreTranslateMessage( MSG * pMsg )
{
      if( WM_KEYFIRST <= pMsg->message && pMsg->message <= WM_KEYLAST )
      {
            HWND hWndFocus = ::GetFocus();
            if( hWndFocus != NULL )
            {
                  CWnd * pWnd = CWnd::FromHandlePermanent( hWndFocus );
                  if( pWnd != NULL )
                  {
                        if( pWnd->IsKindOf( RUNTIME_CLASS( CExtEdit ) ) )
                              return FALSE;
                  }
            }
      }

// your default message pre-translation code goes here
. . .