Click here to Skip to main content
16,014,589 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to find which port is active? Pin
Mad__13-Sep-04 4:49
Mad__13-Sep-04 4:49 
Generalsearching for Nicholl-Lee- Nicholl C or C++ code Pin
gledaoc11-Sep-04 18:26
gledaoc11-Sep-04 18:26 
GeneralRe: searching for Nicholl-Lee- Nicholl C or C++ code Pin
Ravi Bhavnani12-Sep-04 7:16
professionalRavi Bhavnani12-Sep-04 7:16 
Generaldeselecting list ctrl items Pin
Tyrus18211-Sep-04 14:05
Tyrus18211-Sep-04 14:05 
GeneralRe: deselecting list ctrl items Pin
Branislav11-Sep-04 22:32
Branislav11-Sep-04 22:32 
GeneralRe: deselecting list ctrl items Pin
Michael Dunn12-Sep-04 8:49
sitebuilderMichael Dunn12-Sep-04 8:49 
GeneralCreate a flash movie from C++ Windows code Pin
AssemblySoft11-Sep-04 13:59
AssemblySoft11-Sep-04 13:59 
GeneralMouse hook Pin
0v3rloader11-Sep-04 13:26
0v3rloader11-Sep-04 13:26 
Hello,

I have an app installing a mouse hook:

The hook setup function...
BOOL CXCapture::Setup()
{
	DFUNC_DEF(CXCapture::Setup);
	BOOL bRetVal;
	//!CODE_START--->
	m_hMouse = ::SetWindowsHookEx(WH_MOUSE, &MouseProc, ::AfxGetInstanceHandle(), NULL);
	bRetVal = m_hMouse != NULL;
	DFUNC_RET(bRetVal != FALSE, DSTR("Could not initialise mouse_hook (Err#%d)", GetLastError()));
	return bRetVal;
}


The callback function...
LRESULT CALLBACK CXCapture::MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	DFUNC_DEF(CXCapture::MouseProc);
	//!CODE_START--->
	DTRACE(DSTR("Hook: %d::%d, %d", nCode, wParam, lParam));
	// now lets allow the message to be processed
	return ::CallNextHookEx(m_hMouse, nCode, wParam, lParam);
}


It happens that while the mouse is inside my application's (only) dialog box, the callback function (MouseProc) is called flawlessly, but when the mouse focus is out of the window, the OS simply unhooks it.

Therefore, whenever the mouse leaves the app's window focus, I am left out with no mouse hook whatsoever!!

My question is why this is happening and what should (or can) I do in order to solve this.

All feedback is greatly appreciated.

David Nimrod
GeneralRe: Mouse hook Pin
AssemblySoft12-Sep-04 4:53
AssemblySoft12-Sep-04 4:53 
GeneralRe: Mouse hook Pin
0v3rloader12-Sep-04 5:46
0v3rloader12-Sep-04 5:46 
GeneralCRecordset question. Pin
crimsongrape11-Sep-04 12:46
crimsongrape11-Sep-04 12:46 
General_tscanf oddness Pin
Ravi Bhavnani11-Sep-04 11:39
professionalRavi Bhavnani11-Sep-04 11:39 
GeneralRe: _tscanf oddness Pin
Neville Franks11-Sep-04 12:13
Neville Franks11-Sep-04 12:13 
GeneralRe: _tscanf oddness Pin
Ravi Bhavnani11-Sep-04 12:56
professionalRavi Bhavnani11-Sep-04 12:56 
GeneralRe: _tscanf oddness Pin
Joel Holdsworth11-Sep-04 22:33
Joel Holdsworth11-Sep-04 22:33 
GeneralRe: _tscanf oddness Pin
Gary R. Wheeler12-Sep-04 2:50
Gary R. Wheeler12-Sep-04 2:50 
GeneralRe: _tscanf oddness Pin
Joel Holdsworth12-Sep-04 2:55
Joel Holdsworth12-Sep-04 2:55 
GeneralAlpha in GDI Pin
Joel Holdsworth11-Sep-04 9:32
Joel Holdsworth11-Sep-04 9:32 
GeneralRe: Alpha in GDI Pin
Iain Clarke, Warrior Programmer13-Sep-04 3:41
Iain Clarke, Warrior Programmer13-Sep-04 3:41 
GeneralRe: Alpha in GDI Pin
Joel Holdsworth13-Sep-04 7:39
Joel Holdsworth13-Sep-04 7:39 
GeneralReplicating an instance in a multi-threaded app Pin
0v3rloader11-Sep-04 8:56
0v3rloader11-Sep-04 8:56 
GeneralRe: Replicating an instance in a multi-threaded app Pin
Gary R. Wheeler12-Sep-04 2:58
Gary R. Wheeler12-Sep-04 2:58 
GeneralRe: Replicating an instance in a multi-threaded app Pin
0v3rloader12-Sep-04 5:48
0v3rloader12-Sep-04 5:48 
GeneralUsing a critical section in a high priority thread Pin
Chris Hills11-Sep-04 5:28
Chris Hills11-Sep-04 5:28 
GeneralRe: Using a critical section in a high priority thread Pin
Baris Kurtlutepe11-Sep-04 8:33
Baris Kurtlutepe11-Sep-04 8:33 

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.