Help! about PreTranslateMessage
-
Hi: I meet a problem, it has puzzled me for a long time. I create a COM dll which support MFC, several methods was exposured. The implement code of two methods was shown as follow:
STDMETHODIMP CMyComObj::OnConfiguration(long iReserved, BOOL *pbSuccess) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) CMyCfgDlg dlg; int rtn = dlg.DoModal(); *pbSuccess = (rtn == IDOK) ? TRUE : FALSE; return S_OK; } STDMETHODIMP CMyComObj::ShowUIFace(long hParentWnd) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) // declare in header file as CMyUIDlg *pdlg; pdlg = new CMyUIDlg(); if(pdlg != NULL) { pdlg->Create(ID_MYUIDLG,CWnd::Fromhandle((HWND)hParentWnd));//Create success } *pbSuccess = (rtn == IDOK) ? TRUE : FALSE; return S_OK; }
The problem is in the first method call, the dialog shown normal and I can use TAB switch focus from one control to another control. When I use the second method call, the dialog shown normal but can't use TAB to switch focus(It does not take effect). The reason is virtual function PreTranslateMessage was not be processed, What's wrong? Please help me!!! I am seeking... For what? Why did you ask me for what? I don't know! -
Hi: I meet a problem, it has puzzled me for a long time. I create a COM dll which support MFC, several methods was exposured. The implement code of two methods was shown as follow:
STDMETHODIMP CMyComObj::OnConfiguration(long iReserved, BOOL *pbSuccess) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) CMyCfgDlg dlg; int rtn = dlg.DoModal(); *pbSuccess = (rtn == IDOK) ? TRUE : FALSE; return S_OK; } STDMETHODIMP CMyComObj::ShowUIFace(long hParentWnd) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) // declare in header file as CMyUIDlg *pdlg; pdlg = new CMyUIDlg(); if(pdlg != NULL) { pdlg->Create(ID_MYUIDLG,CWnd::Fromhandle((HWND)hParentWnd));//Create success } *pbSuccess = (rtn == IDOK) ? TRUE : FALSE; return S_OK; }
The problem is in the first method call, the dialog shown normal and I can use TAB switch focus from one control to another control. When I use the second method call, the dialog shown normal but can't use TAB to switch focus(It does not take effect). The reason is virtual function PreTranslateMessage was not be processed, What's wrong? Please help me!!! I am seeking... For what? Why did you ask me for what? I don't know!nothing wrong. in MFC, PreTranslateMessage is only function which handles all of messages (similar to windows in Win32). for other function (i.e. WindowProcess), MFC filters (bad design, i think) and adds many messages. typically, it filters TAB, arrow key: up,left,right,down. if TAB doesn't work, normally arrow keys don't work eithr includeh10
-
nothing wrong. in MFC, PreTranslateMessage is only function which handles all of messages (similar to windows in Win32). for other function (i.e. WindowProcess), MFC filters (bad design, i think) and adds many messages. typically, it filters TAB, arrow key: up,left,right,down. if TAB doesn't work, normally arrow keys don't work eithr includeh10