Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help! about PreTranslateMessage

Help! about PreTranslateMessage

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++comquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Simon W 0
    wrote on last edited by
    #1

    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!

    I 1 Reply Last reply
    0
    • S Simon W 0

      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!

      I Offline
      I Offline
      includeh10
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • I 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

        S Offline
        S Offline
        Simon W 0
        wrote on last edited by
        #3

        Thanks,but how to solve this problem? I want "PreTranslateMessage" be called normally. I am seeking... For what? Why did you ask me for what? I don't know!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups