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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Processing Arrow Keys in a Modeless Dialog (DLL)

Processing Arrow Keys in a Modeless Dialog (DLL)

Scheduled Pinned Locked Moved C / C++ / MFC
c++
3 Posts 2 Posters 2 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.
  • J Offline
    J Offline
    Justin Cooke
    wrote on last edited by
    #1

    Greetings All, I'm trying to process the arrow keys in a modeless dialog implemented as a DLL (MFC.) I've tried various methods based on what I've found on CodeProject, but none have worked. OnKeyDown() and PreTranslateMessage() are never called in my dlg. Instead, PreTranslateMessage() in the client application that uses the DLL is called whenever I press the keys. I also tried overriding OnGetDlgCode() in my DLL dlg class and returning DLGC_WANTMESSAGE and DLGC_WANTALLKEYS, but that also had no effect. I can't change anything in the client app to handle this because I'm not normally in control of that. Any suggestions would be greatly appreciated. Thanks, Justin

    M 1 Reply Last reply
    0
    • J Justin Cooke

      Greetings All, I'm trying to process the arrow keys in a modeless dialog implemented as a DLL (MFC.) I've tried various methods based on what I've found on CodeProject, but none have worked. OnKeyDown() and PreTranslateMessage() are never called in my dlg. Instead, PreTranslateMessage() in the client application that uses the DLL is called whenever I press the keys. I also tried overriding OnGetDlgCode() in my DLL dlg class and returning DLGC_WANTMESSAGE and DLGC_WANTALLKEYS, but that also had no effect. I can't change anything in the client app to handle this because I'm not normally in control of that. Any suggestions would be greatly appreciated. Thanks, Justin

      M Offline
      M Offline
      mangellj
      wrote on last edited by
      #2

      If you haven't already tried it, consider overridding the modeless Dialog's DefWindowProc and handling the WM_KEYDOWN there. If you have already tried it and it didn't work, sorry for wasting your time.

      J 1 Reply Last reply
      0
      • M mangellj

        If you haven't already tried it, consider overridding the modeless Dialog's DefWindowProc and handling the WM_KEYDOWN there. If you have already tried it and it didn't work, sorry for wasting your time.

        J Offline
        J Offline
        Justin Cooke
        wrote on last edited by
        #3

        I hadn't tried it yet, but I did today and I still had the same problem. Thanks for the advice, though. Not a waste of time at all :) I had forgotten about that particular override. By the way, I found a description on MS' website about how to call a "FilterDllMsg()" func from the main app's PreTranslateMessage() and that, at least, allowed me to recieve the key messages in the dialog. (I'd rather be able to do this without modifying the main app code, but it's a start.) However, I have a wierd crash bug now that goes away if I change the "m_pMainWnd = &dlg;" line in my main app's InitInstance() func to "m_pMainWnd = NULL;" If I press a key in the dialog, the DLL/app freeze. I'm probably going to post another question about this problem. Thanks Again, Justin Here's the link to the MS sample: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/vcsamDllScreenCapSample.asp

        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