Click here to Skip to main content
15,908,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: GetDirectory? Pin
David Crow22-Oct-08 3:19
David Crow22-Oct-08 3:19 
AnswerRe: GetDirectory? Pin
Sandeep Saini SRE22-Oct-08 18:16
Sandeep Saini SRE22-Oct-08 18:16 
QuestionCant find error in MFC code Pin
m_mun22-Oct-08 1:56
m_mun22-Oct-08 1:56 
AnswerRe: Cant find error in MFC code Pin
James R. Twine22-Oct-08 2:10
James R. Twine22-Oct-08 2:10 
QuestionRe: Cant find error in MFC code Pin
David Crow22-Oct-08 3:21
David Crow22-Oct-08 3:21 
QuestionHook for hide a IE instance Pin
vicky0000022-Oct-08 1:44
vicky0000022-Oct-08 1:44 
QuestionWhy write double symbol? Pin
mantas1234522-Oct-08 1:44
mantas1234522-Oct-08 1:44 
AnswerRe: Why write double symbol? Pin
Iain Clarke, Warrior Programmer22-Oct-08 3:18
Iain Clarke, Warrior Programmer22-Oct-08 3:18 
This really is a job for your debugger, but I'll try to help!

First, you set a hook for WH_KEYBOARD_LL (13). If possible, please use the constants - or comment the code at least as to why you didn't.

This hooks WM_KEYUP, and WM_KEYDOWN messages (and a few others).

So, you press down the 'A' key.

A WM_KEYDOWN message is sent.

Your hook gets called. You then call ::GetKeyState(VK_DOWN). Look at the help, and you see that it returns some complex code telling you about the status of the down arrow key on your keyboard. This is unlikely to be 0, so end up logging the 'A'.

Then you let go of the 'A' key shortly after.

A WM_KEYUP is sent, and it fires your hook.
That also checks the VK_DOWN key, finds some status that isn't 0, and logs the 'A' key again.

If you only want to log when a key is pushed down (my psychic abilities here), then change your hook to...

LRESULT CALLBACK HookKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
  // do we care about this message?
  if((wParam == WM_KEYDOWN) || (wParam == WM_SYSKEYDOWN))
  {
    KBDLLHOOKSTRUCT *kb = (KBDLLHOOKSTRUCT *)lParam;
    // log the VK code, as it's a 0-254 by definition;
    BYTE byOut = (BYTE) (kb->vkCode);

    FILE* fout = fopen("log.txt", "a+");
    if (fout)
    {
      fwrite(&byOut, 1, 1, fout);
      fclose(fout);
    }
  }
  // call next hook in the chain
  return CallNextHookEx( hHook, nCode, wParam, lParam);
}

Questiondoes not show jpeg in loaded URL's :-( Pin
ennogir22-Oct-08 1:44
ennogir22-Oct-08 1:44 
QuestionPrinting using win32 (print to pdf) Pin
koderbytes22-Oct-08 1:39
koderbytes22-Oct-08 1:39 
QuestionUpload a file to server using http Pin
Dhiraj kumar Saini22-Oct-08 1:23
Dhiraj kumar Saini22-Oct-08 1:23 
QuestionRe: Upload a file to server using http Pin
led mike22-Oct-08 4:34
led mike22-Oct-08 4:34 
Questioninteger/long to variant* Pin
SRKSHOME22-Oct-08 1:05
SRKSHOME22-Oct-08 1:05 
QuestionRe: integer/long to variant* Pin
CPallini22-Oct-08 2:14
mveCPallini22-Oct-08 2:14 
AnswerRe: integer/long to variant* Pin
SRKSHOME22-Oct-08 2:27
SRKSHOME22-Oct-08 2:27 
QuestionRe: integer/long to variant* Pin
CPallini22-Oct-08 2:39
mveCPallini22-Oct-08 2:39 
AnswerRe: integer/long to variant* Pin
SRKSHOME22-Oct-08 3:21
SRKSHOME22-Oct-08 3:21 
AnswerRe: integer/long to variant* Pin
Roger Stoltz22-Oct-08 2:40
Roger Stoltz22-Oct-08 2:40 
AnswerRe: integer/long to variant* Pin
Iain Clarke, Warrior Programmer22-Oct-08 2:57
Iain Clarke, Warrior Programmer22-Oct-08 2:57 
AnswerRe: integer/long to variant* Pin
David Crow22-Oct-08 3:25
David Crow22-Oct-08 3:25 
QuestionHow to convert BYTE array into equivalent string data ? Pin
kapardhi22-Oct-08 0:52
kapardhi22-Oct-08 0:52 
AnswerRe: How to convert BYTE array into equivalent string data ? Pin
Iain Clarke, Warrior Programmer22-Oct-08 0:58
Iain Clarke, Warrior Programmer22-Oct-08 0:58 
GeneralRe: How to convert BYTE array into equivalent string data ? Pin
kapardhi22-Oct-08 1:06
kapardhi22-Oct-08 1:06 
QuestionShell Integration problem Pin
GRLEX22-Oct-08 0:26
GRLEX22-Oct-08 0:26 
AnswerRe: Shell Integration problem Pin
CPallini22-Oct-08 0:48
mveCPallini22-Oct-08 0:48 

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.