Click here to Skip to main content
15,907,326 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to parse non string data Pin
Arris7430-Apr-07 4:57
Arris7430-Apr-07 4:57 
GeneralRe: how to parse non string data Pin
CPallini30-Apr-07 5:24
mveCPallini30-Apr-07 5:24 
GeneralRe: how to parse non string data Pin
David Crow30-Apr-07 5:42
David Crow30-Apr-07 5:42 
GeneralRe: how to parse non string data Pin
CPallini30-Apr-07 7:26
mveCPallini30-Apr-07 7:26 
GeneralRe: how to parse non string data Pin
Arris7430-Apr-07 5:54
Arris7430-Apr-07 5:54 
GeneralRe: how to parse non string data Pin
CPallini30-Apr-07 7:28
mveCPallini30-Apr-07 7:28 
QuestionOwner draw Radio button event Handling Pin
Shailesh Namjoshi30-Apr-07 3:37
Shailesh Namjoshi30-Apr-07 3:37 
QuestionHow to hook WM_MOUSEHOVER and WM_NCMOUSEHOVER? [modified] Pin
uckf60930-Apr-07 3:10
uckf60930-Apr-07 3:10 
Here is my code:
<br />
#define WINVER 0x0500<br />
#include <windows.h><br />
<br />
#define WM_MOUSEHOVER                   0x02A1<br />
#define WM_NCMOUSEHOVER                 0x02A0<br />
<br />
<br />
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);<br />
<br />
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpszCmdLine,int nCmdShow)<br />
{<br />
	HWND hwnd;		<br />
	MSG msg;		<br />
	WNDCLASS wndclass;		<br />
	TCHAR* szAppName = TEXT("MOUSEHOVER");	<br />
	wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);	<br />
	wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);		<br />
	wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);	<br />
	wndclass.lpszClassName = szAppName;		<br />
	wndclass.cbClsExtra = 0;		<br />
	wndclass.cbWndExtra = 0;		<br />
							<br />
	wndclass.lpszMenuName = NULL;	<br />
	wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ;<br />
	wndclass.lpfnWndProc = WndProc;		<br />
	wndclass.hInstance = hInstance;		<br />
<br />
	if( !RegisterClass(&wndclass) )		<br />
		return 0;<br />
	hwnd = CreateWindow(			<br />
				szAppName,		<br />
				szAppName,		<br />
				WS_OVERLAPPEDWINDOW,	<br />
				CW_USEDEFAULT,		<br />
				CW_USEDEFAULT,		<br />
				CW_USEDEFAULT,			<br />
				CW_USEDEFAULT,		<br />
				NULL,				<br />
				NULL,				<br />
				hInstance,		<br />
				NULL		<br />
				);<br />
	ShowWindow( hwnd,nCmdShow );<br />
	UpdateWindow( hwnd );<br />
	while( GetMessage(&msg,NULL,0,0) )<br />
	{<br />
		TranslateMessage(&msg);	<br />
		DispatchMessage(&msg);<br />
	}	<br />
	return msg.wParam;<br />
}<br />
<br />
LRESULT CALLBACK MouseProc( int nCode, WPARAM wParam, LPARAM lParam )<br />
{<br />
	switch( wParam )<br />
	{<br />
	case WM_MOUSEHOVER:<br />
		MessageBox( ((PMOUSEHOOKSTRUCT)lParam)->hwnd, TEXT("mousehover hooked"), TEXT("mousehover"), MB_OK);<br />
		break;<br />
	case WM_NCMOUSEHOVER:<br />
		MessageBox( ((PMOUSEHOOKSTRUCT)lParam)->hwnd, TEXT("ncmousehover hooked"), TEXT("ncmousehover"), MB_OK);<br />
	case WM_LBUTTONDOWN:<br />
		MessageBox(((PMOUSEHOOKSTRUCT)lParam)->hwnd, TEXT("lbuttondown hooked"), TEXT("lbuttondown"), MB_OK);<br />
		break;<br />
	}<br />
	return CallNextHookEx(NULL, nCode, wParam, lParam);<br />
}<br />
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )<br />
{<br />
	switch( message )<br />
	{<br />
	case WM_CREATE:<br />
		{		<br />
			SetWindowsHookEx(WH_MOUSE,MouseProc,<br />
				((LPCREATESTRUCT)lParam)->hInstance,<br />
				GetCurrentThreadId());<br />
			return 0;<br />
		}<br />
	case WM_MOUSEMOVE:<br />
		{<br />
			TRACKMOUSEEVENT tme;<br />
			tme.cbSize = sizeof(tme);<br />
			tme.dwFlags = TME_HOVER/* | TME_NONCLIENT*/;<br />
			tme.dwHoverTime = 500;<br />
			tme.hwndTrack = hwnd;<br />
<br />
			TrackMouseEvent(&tme);<br />
<br />
			return 0;<br />
		}<br />
	case WM_MOUSEHOVER:<br />
		MessageBox(hwnd, TEXT("mousehover"), TEXT("mouseHover"), MB_OK);<br />
		return 0;<br />
	case WM_NCMOUSEHOVER:<br />
		MessageBox(hwnd,TEXT("ncmouseHover"), TEXT("ncMouseHover"), MB_OK);<br />
		return 0;<br />
	case WM_LBUTTONDOWN:<br />
		MessageBox(hwnd,TEXT("lbuttondown"), TEXT("lbuttondown"), MB_OK);<br />
		return 0;<br />
	case WM_DESTROY:<br />
		PostQuitMessage(0);<br />
		return 0;<br />
	}<br />
	return DefWindowProc( hwnd, message, wParam, lParam );<br />
}<br />


When the cursor hovers over the window for a period of time, only the message box with the content being "mousehover" pops up ,while the one called in the MouseProc does not.But WM_LBUTTONDOWN is hooked successfully.
Can any one explain why and tell me how to hook WM_MOUSEHOVER and WM_NCMOUSEHOVER?

Besides,when I use TME_HOVER and TME_NONCLIENT together, no message box pops up at all except those due to mouse clicks. Is it because WM_NCMOUSEMOVE is generated instead of WM_MOUSEMOVE,which leads to the failure of call to TrackMouseEvent? How can I use TME_HOVER and TME_NONCLIENT together?

Thank you


-- modified at 3:30 Tuesday 1st May, 2007
AnswerRe: How to hook WM_MOUSEHOVER and WM_NCMOUSEHOVER? Pin
lihai42529-Nov-09 21:01
lihai42529-Nov-09 21:01 
QuestionDownloading file from http Pin
deeps_cute30-Apr-07 3:06
deeps_cute30-Apr-07 3:06 
AnswerRe: Downloading file from http Pin
kakan30-Apr-07 3:25
professionalkakan30-Apr-07 3:25 
AnswerRe: Downloading file from http Pin
near2world30-Apr-07 3:29
near2world30-Apr-07 3:29 
GeneralRe: Downloading file from http Pin
deeps_cute30-Apr-07 3:33
deeps_cute30-Apr-07 3:33 
AnswerRe: Downloading file from http Pin
Ravi Bhavnani30-Apr-07 3:37
professionalRavi Bhavnani30-Apr-07 3:37 
GeneralRe: Downloading file from http Pin
near2world1-May-07 0:26
near2world1-May-07 0:26 
QuestionAPIs to get the deive information Pin
sheela Rajaram30-Apr-07 3:05
sheela Rajaram30-Apr-07 3:05 
QuestionStrange Problems with Memory- and Object-Access Pin
J. Holzer30-Apr-07 2:39
J. Holzer30-Apr-07 2:39 
AnswerRe: Strange Problems with Memory- and Object-Access Pin
kakan30-Apr-07 2:49
professionalkakan30-Apr-07 2:49 
GeneralRe: Strange Problems with Memory- and Object-Access Pin
J. Holzer30-Apr-07 2:51
J. Holzer30-Apr-07 2:51 
GeneralRe: Strange Problems with Memory- and Object-Access Pin
kakan30-Apr-07 2:55
professionalkakan30-Apr-07 2:55 
GeneralRe: Strange Problems with Memory- and Object-Access Pin
J. Holzer30-Apr-07 3:39
J. Holzer30-Apr-07 3:39 
GeneralRe: Strange Problems with Memory- and Object-Access Pin
kakan30-Apr-07 3:52
professionalkakan30-Apr-07 3:52 
QuestionIf particular machine is active or not on a LAN Pin
Mushtaque Nizamani30-Apr-07 2:13
Mushtaque Nizamani30-Apr-07 2:13 
AnswerRe: If particular machine is active or not on a LAN Pin
kakan30-Apr-07 2:29
professionalkakan30-Apr-07 2:29 
AnswerRe: If particular machine is active or not on a LAN Pin
David Crow30-Apr-07 2:54
David Crow30-Apr-07 2:54 

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.