Click here to Skip to main content
15,918,742 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Help not sure why. [modified] Pin
FISH78630-Mar-09 4:36
FISH78630-Mar-09 4:36 
GeneralRe: Help not sure why. Pin
David Crow30-Mar-09 4:54
David Crow30-Mar-09 4:54 
GeneralRe: Help not sure why. Pin
FISH78630-Mar-09 4:59
FISH78630-Mar-09 4:59 
GeneralRe: Help not sure why. Pin
FISH78630-Mar-09 13:36
FISH78630-Mar-09 13:36 
QuestionMultiple Inheritance problem : CSingleLock : CSingleLock(pObject, bInitialLock) : CSyncObject(mystring) Pin
ForNow29-Mar-09 7:18
ForNow29-Mar-09 7:18 
QuestionRe: Multiple Inheritance problem : CSingleLock : CSingleLock(pObject, bInitialLock) : CSyncObject(mystring) Pin
CPallini29-Mar-09 7:51
mveCPallini29-Mar-09 7:51 
AnswerRe: Multiple Inheritance problem : CSingleLock : CSingleLock(pObject, bInitialLock) : CSyncObject(mystring) Pin
ForNow29-Mar-09 12:18
ForNow29-Mar-09 12:18 
Questionhave you ever seen this error? Pin
cs6008929-Mar-09 2:59
cs6008929-Mar-09 2:59 
AnswerRe: have you ever seen this error? Pin
cs6008929-Mar-09 3:00
cs6008929-Mar-09 3:00 
AnswerRe: have you ever seen this error? Pin
CPallini29-Mar-09 3:49
mveCPallini29-Mar-09 3:49 
AnswerRe: have you ever seen this error? Pin
Stuart Dootson29-Mar-09 3:49
professionalStuart Dootson29-Mar-09 3:49 
Questionhave you ever seen this error? Pin
cs6008929-Mar-09 2:58
cs6008929-Mar-09 2:58 
QuestionSHADOW COPY IN C Pin
ADELMAR3E29-Mar-09 2:48
ADELMAR3E29-Mar-09 2:48 
QuestionRe: SHADOW COPY IN C Pin
David Crow29-Mar-09 12:35
David Crow29-Mar-09 12:35 
QuestionInclude issues Pin
gamefreak229128-Mar-09 19:02
gamefreak229128-Mar-09 19:02 
AnswerRe: Include issues Pin
Garth J Lancaster28-Mar-09 20:39
professionalGarth J Lancaster28-Mar-09 20:39 
GeneralRe: Include issues Pin
gamefreak229128-Mar-09 22:01
gamefreak229128-Mar-09 22:01 
AnswerRe: Include issues Pin
Stuart Dootson28-Mar-09 22:15
professionalStuart Dootson28-Mar-09 22:15 
GeneralRe: Include issues Pin
gamefreak229128-Mar-09 22:22
gamefreak229128-Mar-09 22:22 
GeneralRe: Include issues Pin
Stuart Dootson28-Mar-09 22:48
professionalStuart Dootson28-Mar-09 22:48 
The thing is that BlockInput only blocks the input queue of the thread it's executed in - at least that's what the documentation[^] says, so your separate process implementation can't work, as it can only block its own input.

Also - a keyboard hook doesn't need a DLL if it's just for your current thread. The following code adds a hook to the calling thread that blocks input if the 'A' key is pressed. To activate it, you just need to call the StartBlockingFilter function.

HHOOK myHook = 0;

LRESULT CALLBACK KeyboardFilter(int code, WPARAM wParam, LPARAM lParam)
{
   if (wParam == 'a' || wParam == 'A')
      BlockInput(TRUE);
   return CallNextHookEx(myHook, code, wParam, lParam);
}

void StartBlockingFilter()
{
   myHook = ::SetWindowsHookEx(WH_KEYBOARD, &KeyboardFilter, 0, GetCurrentThreadId());
}

void FinishBlockingFilter()
{
   BlockInput(FALSE);
   ::UnhookWindowsHookEx(myHook);
}


You could put this code in a .cpp file, #include it and call StartBlockingFilter from where it was included.

Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: Include issues Pin
gamefreak229129-Mar-09 10:07
gamefreak229129-Mar-09 10:07 
GeneralRe: Include issues Pin
Stuart Dootson29-Mar-09 10:10
professionalStuart Dootson29-Mar-09 10:10 
GeneralRe: Include issues Pin
gamefreak229129-Mar-09 10:17
gamefreak229129-Mar-09 10:17 
GeneralRe: Include issues Pin
Stuart Dootson29-Mar-09 10:30
professionalStuart Dootson29-Mar-09 10:30 
GeneralRe: Include issues Pin
gamefreak229129-Mar-09 11:02
gamefreak229129-Mar-09 11:02 

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.