Click here to Skip to main content
15,905,963 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to get the status of a USB printer. Pin
ashwath200522-Mar-06 0:58
ashwath200522-Mar-06 0:58 
QuestionDisabling item in MENUBAR Pin
Killer322-Mar-06 0:25
Killer322-Mar-06 0:25 
AnswerRe: Disabling item in MENUBAR Pin
ashokbngr22-Mar-06 0:37
ashokbngr22-Mar-06 0:37 
AnswerRe: Disabling item in MENUBAR Pin
Nibu babu thomas22-Mar-06 0:54
Nibu babu thomas22-Mar-06 0:54 
GeneralRe: Disabling item in MENUBAR Pin
Killer322-Mar-06 2:33
Killer322-Mar-06 2:33 
GeneralRe: Disabling item in MENUBAR Pin
Ștefan-Mihai MOGA22-Mar-06 2:47
professionalȘtefan-Mihai MOGA22-Mar-06 2:47 
GeneralRe: Disabling item in MENUBAR Pin
Nibu babu thomas22-Mar-06 16:56
Nibu babu thomas22-Mar-06 16:56 
QuestionHigh CPU with Mouse Global Hook Pin
redfish3422-Mar-06 0:11
redfish3422-Mar-06 0:11 
From Code Project articles i have coded a C++ DLL to be used as a global hook for C# projects. I have been successful in getting a global keyboard hook working. But when i try the same with a mouse hook, computer CPU goes to 100% and C# app gets a million messages that say the same thing. I am not the greatest C++ programmer. Am i missing something here? I think i have all the code parts needed?

Below is the code i am using (40+ lines):

#include "stdafx.h"
#include "hookdll.h"

#pragma data_seg("SHARED")
HHOOK m_mouseHook = NULL;
HWND m_hHookClient = NULL;
#pragma data_seg()
#pragma comment(linker, "/SECTION:SHARED,RWS") // linker directive

HINSTANCE m_hHookDLL = NULL;

const int GH_MOUSEOTHER = WM_USER + 4099;

BOOL APIENTRY DllMain(
HANDLE hInstance,
DWORD callReason,
LPVOID reserved)
{
switch (callReason)
{
case DLL_PROCESS_ATTACH:
m_hHookDLL = (HINSTANCE)hInstance;
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

extern "C" __declspec(dllexport) void InstallHook(HWND hWnd)
{
m_mouseHook = NULL;
m_hHookClient = hWnd;

// set mouse hook
m_mouseHook = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)MouseHookProc,
m_hHookDLL, NULL);
}

extern "C" __declspec(dllexport) void RemoveHook()
{
UnhookWindowsHookEx(m_mouseHook);
}

LRESULT CALLBACK MouseHookProc(
int nCode,
WPARAM wParam,
LPARAM lParam)
{
if (nCode >= 0)
{
PostMessage(m_hHookClient, GH_MOUSEOTHER, wParam, lParam);
}

// pass control to next hook in the hook chain
return CallNextHookEx(NULL, nCode, wParam, lParam);
}


-- modified at 6:15 Wednesday 22nd March, 2006
QuestionNid help in getting list of URLS in a webpage/website Pin
SteelCrow21-Mar-06 23:50
SteelCrow21-Mar-06 23:50 
AnswerRe: Nid help in getting list of URLS in a webpage/website Pin
Giannakakis Kostas22-Mar-06 1:13
professionalGiannakakis Kostas22-Mar-06 1:13 
GeneralRe: Nid help in getting list of URLS in a webpage/website Pin
SteelCrow22-Mar-06 16:02
SteelCrow22-Mar-06 16:02 
GeneralRe: Nid help in getting list of URLS in a webpage/website Pin
Giannakakis Kostas22-Mar-06 19:02
professionalGiannakakis Kostas22-Mar-06 19:02 
QuestionHow to get window's color? Pin
at2000121-Mar-06 23:23
at2000121-Mar-06 23:23 
AnswerRe: How to get window's color? Pin
Hamid_RT21-Mar-06 23:39
Hamid_RT21-Mar-06 23:39 
Questionprinting Pin
_tasleem21-Mar-06 23:20
_tasleem21-Mar-06 23:20 
AnswerRe: printing Pin
Monty221-Mar-06 23:43
Monty221-Mar-06 23:43 
AnswerRe: printing Pin
Hamid_RT22-Mar-06 8:45
Hamid_RT22-Mar-06 8:45 
QuestionAutomatization help needed Pin
Radu Sorin21-Mar-06 23:18
Radu Sorin21-Mar-06 23:18 
AnswerRe: Automatization help needed Pin
Giannakakis Kostas22-Mar-06 1:28
professionalGiannakakis Kostas22-Mar-06 1:28 
QuestionLoading of one jpeg on to another jpeg Pin
RahulOP21-Mar-06 23:12
RahulOP21-Mar-06 23:12 
AnswerRe: Loading of one jpeg on to another jpeg Pin
Monty221-Mar-06 23:56
Monty221-Mar-06 23:56 
QuestionWorking with DLL Pin
chaitanya2221-Mar-06 23:03
chaitanya2221-Mar-06 23:03 
AnswerRe: Working with DLL Pin
Cedric Moonen21-Mar-06 23:19
Cedric Moonen21-Mar-06 23:19 
Questioncommand line instructions Pin
chetan21018321-Mar-06 22:58
chetan21018321-Mar-06 22:58 
AnswerRe: command line instructions Pin
toxcct21-Mar-06 22:59
toxcct21-Mar-06 22:59 

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.