Re: Accelerators don't work when focus is inside a common control
I am sorry but I couldn't recreate the problem. I kinda didn't understand
the diagram you posted. Is there a CView derived class that's a parent of a
CWnd derived class which is a parent of a CEdit? May I ask why the CWnd is
not a CDialog?
But here is what I am doing. I created an SDI application, with a splitter.
The view was a CFormView with an edit control in it.
Here is the code in the main frame (with this code the accelerator works no
matter where the focus is at)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
ON_COMMAND(ID_MYITEM_FIRSTITEM, OnMyitemFirstitem)
END_MESSAGE_MAP()
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
......
m_hAccel =
::LoadAccelerators(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_ACCELERATOR1))
;
return 0;
}
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
{
// Translate the message using accelerator table
ASSERT(m_hAccel);
if (TranslateAccelerator(m_hWnd, m_hAccel, pMsg))
{
return TRUE;
}
}
return CFrameWnd::PreTranslateMessage(pMsg);
}
"si" <nomail@nospan.no> wrote in message
news:ubFSdAqqGHA.4032@TK2MSFTNGP03.phx.gbl...
AliR wrote:
You shouldn't have to catch anything in the edit control to get this
working.
What I was asking is where are the ON_COMMAND message handlers for the
id's
in the accelerator table.
If they are in a particular view for instance, then won't be called if
the
focus is in a different type view.
If that's not the case then let me know exactly where your ON_COMMANDs
are
and I'll try to recreate your problem.
AliR.
"si" <nomail@nospan.no> wrote in message
news:ehsCHJoqGHA.644@TK2MSFTNGP05.phx.gbl...
AliR wrote:
ON_COMMAND handlers are in the MainFrame, the focus is in a CEdit
control. It looks like this:
MainFrame <- here are the handlers
|
SplitterWnd
|
View (in the first pane if that matters)
|
CWnd derived class
|
CEdit <- focus
si