c++ - Control for getting hotkeys like tab and space -


i have dialog box allows users set hotkeys use in 3d program on windows. i'm using chotkeyctrl, pretty good, doesn't handle keys users use - specifically, tab , space.

the hotkey handling smart enough able fire on keys, need ui let them set. control similar chotkeyctrl ideal, other workarounds appreciated.

one workarounds option use stock standard edit control message hook function.

this allow trap keyboard wm_keydown messages sent edit control.

the hook function this:

    lresult callback messagehook(int code, wparam wparam, lpmsg lpmsg)     {       lresult lresult = 0;        if ((code >= 0) && (code == msgf_dialogbox))       {         if (lpmsg->message == wm_keydown)         {           //-- process key down message           lresult = 1;         }       }        // default processing if required       if (lresult == 0)       {         lresult = callnexthookex(messagefilterhook, code, wparam, (lparam)lpmsg);       }        return lresult;     } 

the hook can attached edit control when edit control gets focus follows:

    //-- create instance thunk our hook callback     farproc filterproc = (farproc) makeprocinstance((hookproc)(messagehook),                                                     hinstance);     //-- attach message hook     filterhook = setwindowshookex(wh_msgfilter,                                   (hookproc)filterproc,                                    hinstance, getcurrentthreadid()); 

and removed when edit control when looses focus follows:

    //-- remove message hook     unhookwindowshookex(messagefilterhook); 

using approach every key press sent hook, provided edit control has focus.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -