Click here to Skip to main content
15,886,362 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Connect to all LAN servers Pin
Manmohan2922-Feb-10 3:52
Manmohan2922-Feb-10 3:52 
QuestionVS 2003/2008 or GCC Need To Choose! Pin
Trevor Johansen20-Feb-10 13:02
Trevor Johansen20-Feb-10 13:02 
AnswerRe: VS 2003/2008 or GCC Need To Choose! Pin
Nemanja Trifunovic20-Feb-10 16:06
Nemanja Trifunovic20-Feb-10 16:06 
QuestionAgain KeyBoar dll Pin
devidmorton20-Feb-10 10:59
devidmorton20-Feb-10 10:59 
AnswerRe: Again KeyBoar dll Pin
CPallini20-Feb-10 11:16
mveCPallini20-Feb-10 11:16 
AnswerRe: Again KeyBoar dll Pin
Trevor Johansen20-Feb-10 12:51
Trevor Johansen20-Feb-10 12:51 
GeneralRe: Again KeyBoar dll Pin
devidmorton21-Feb-10 5:26
devidmorton21-Feb-10 5:26 
GeneralRe: Again KeyBoar dll Pin
Trevor Johansen3-Mar-10 19:04
Trevor Johansen3-Mar-10 19:04 
This is the relevant info from my project in the file: PluginTestDlg.cpp

<br />
#include "KeyHook.h"<br />
<br />
// ID of the notification message that will be sent to us<br />
#define WM_MY_MESSAGE (WM_APP + 100)<br />
<br />
ON_MESSAGE(WM_MY_MESSAGE, OnMyMessage) // Maps our message<br />
<br />
// Install the hook<br />
LRESULT lRes = InstallKeyHook();<br />
ASSERT(lRes == KH_OK);  // Check if passed<br />
<br />
// Prepare the KEYENTRY struct<br />
KEYENTRY ke;<br />
ke.nMessage = WM_MY_MESSAGE; // Our message ID<br />
ke.hCallWnd = m_hWnd; // Send message to this window<br />
ke.hHookWnd = 0; // Capture key-strokes occurred in any windows<br />
ke.iCombKeys = 0; // Combination key states do not matter<br />
ke.iIndicators = 0; // Caps-lock, Num-lock, Scroll-lock on/off states do not matter<br />
ke.iKeyEvent = KH_KEY_DOWN | KH_KEY_UP; // Capture key-down and key-up events<br />
ke.iMinVKCode = 0; // Capture all keys regardless of their virtual key codes<br />
ke.iMaxVKCode = 255;<br />
<br />
// Add the entry to the hook<br />
lRes = AddKeyEntry(&ke);<br />
ASSERT(lRes == KH_OK);  // Check if passed<br />
    <br />
<br />
// Handler of WM_MY_MESSAGE notification<br />
LRESULT CPluginTestDlg::OnMyMessage(WPARAM wParam, LPARAM lParam)<br />
{<br />
    // The struct to receive information<br />
    KEYRESULT kr; <br />
<br />
    // Information that we need to extract are event type and printable character<br />
    UINT nMask = KH_MASK_EVENTTYPE | KH_MASK_PRINTABLECHAR;<br />
 <br />
    // This function extracts event details<br />
    LRESULT lRes = GetKeyEventResult(wParam, lParam, &kr, nMask);<br />
    ASSERT(lRes == KH_OK);  // Check if passed<br />
<br />
    // We only display key-strokes that produce printable characters<br />
    if (kr.chPrintableChar != 0)<br />
    {<br />
        CString sEvent;<br />
        if (kr.iKeyEvent == KH_KEY_DOWN)<br />
            sEvent = _T("Key Down");<br />
        else if (kr.iKeyEvent == KH_KEY_UP)<br />
            sEvent = _T("Key Up");<br />
        else if (kr.iKeyEvent == KH_KEY_REPEAT)<br />
            sEvent = _T("Key Repeat");<br />
        else<br />
            ASSERT(FALSE); // will never happen<br />
<br />
        CString sMsg;<br />
        sMsg.Format(_T("Event: %s\nCharacter:%c"), sEvent, kr.chPrintableChar);<br />
        MessageBox(sMsg); // display the result<br />
    }<br />
<br />
    return (LRESULT)0;<br />
}<br />
<br />
<br />
// Remove the hook<br />
UninstallKeyHook();<br />


-The ke structure is how you setup the hook and all options are documented in the KeyHook.h header
-In my kr structure I use the nMask to decode the message unto useful info then check if its a printable character and issue a msgbox for each type of key state.
-ASSERT(lRes == KH_OK);is a sanity check, error codes are listed in KeyHook.h
-#define WM_MY_MESSAGE (WM_APP + 100) I have no idea where I got this from... But it works...

Sorry to reply so late I have been away for work.
QuestionC code in VC Pin
Punima Sen20-Feb-10 5:34
Punima Sen20-Feb-10 5:34 
AnswerRe: C code in VC Pin
David Crow20-Feb-10 6:12
David Crow20-Feb-10 6:12 
AnswerRe: C code in VC Pin
CPallini20-Feb-10 11:15
mveCPallini20-Feb-10 11:15 
AnswerRe: C code in VC Pin
Rajesh R Subramanian21-Feb-10 1:02
professionalRajesh R Subramanian21-Feb-10 1:02 
Questionmfc receive sms [modified] Pin
saneevil20-Feb-10 3:16
saneevil20-Feb-10 3:16 
AnswerRe: mfc receive sms Pin
CPallini20-Feb-10 4:16
mveCPallini20-Feb-10 4:16 
QuestionMore help sought for my Monitoring and Controlling Worker Thread article... Pin
Ben Aldhouse20-Feb-10 2:11
Ben Aldhouse20-Feb-10 2:11 
AnswerRe: More help sought for my Monitoring and Controlling Worker Thread article... Pin
Stephen Hewitt20-Feb-10 3:24
Stephen Hewitt20-Feb-10 3:24 
GeneralRe: More help sought for my Monitoring and Controlling Worker Thread article... Pin
Ben Aldhouse20-Feb-10 21:35
Ben Aldhouse20-Feb-10 21:35 
AnswerRe: More help sought for my Monitoring and Controlling Worker Thread article... Pin
Randor 20-Feb-10 11:53
professional Randor 20-Feb-10 11:53 
GeneralRe: More help sought for my Monitoring and Controlling Worker Thread article... Pin
Ben Aldhouse20-Feb-10 21:43
Ben Aldhouse20-Feb-10 21:43 
GeneralRe: More help sought for my Monitoring and Controlling Worker Thread article... Pin
Ben Aldhouse26-Feb-10 11:49
Ben Aldhouse26-Feb-10 11:49 
GeneralRe: More help sought for my Monitoring and Controlling Worker Thread article... Pin
Ben Aldhouse13-Apr-10 10:38
Ben Aldhouse13-Apr-10 10:38 
Questionhow do i send a long sms exceeding 160 characters using AT command? Pin
Le@rner20-Feb-10 1:03
Le@rner20-Feb-10 1:03 
AnswerRe: how do i send a long sms exceeding 160 characters using AT command? PinPopular
Richard MacCutchan20-Feb-10 4:05
mveRichard MacCutchan20-Feb-10 4:05 
QuestionHow Do display a Name in place of SMS sender phone no using AT Commands? Pin
Le@rner19-Feb-10 23:43
Le@rner19-Feb-10 23:43 
AnswerRe: How Do display a Name in place of SMS sender phone no using AT Commands? Pin
Garth J Lancaster20-Feb-10 0:10
professionalGarth J Lancaster20-Feb-10 0:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.