matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: [?] WM_MOUSEMOVE doesn't work
This example is from here: http://www.codeguru.com/forum/showthread.php?t=290195
c++ code: //////////// Globals ////////////
// HWND hWndBtn1 = NULL;
// HWND hWndBtn2 = NULL;
// WNDPROC wpOrigButtonProc = NULL;
// HBITMAP hBmpNormal = NULL;
// HBITMAP hBmpHiLight = NULL;
// BOOL bMouseInWindow = FALSE;
// IDC_DLGBTN1 is a button resource
// IDC_DLGBTN2 is a button resource
// IDB_BMP_NORMAL is a bitmap resource
// IDB_BMP_HILIGHT is a bitmap resource
// in WM_INITDIALOG of main dialog procedure
hWndBtn1 = GetDlgItem(hWnd, IDC_DLGBTN1);
hWndBtn2 = GetDlgItem(hWnd, IDC_DLGBTN2);
// load bitmaps
hBmpNormal = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BMP_NORMAL));
hBmpHiLight = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BMP_HILIGHT));
// set initial button images
SendMessage(hWndBtn1, BM_SETIMAGE,
(WPARAM)IMAGE_BITMAP, (LPARAM)hBmpNormal );
SendMessage(hWndBtn2, BM_SETIMAGE,
(WPARAM)IMAGE_BITMAP, (LPARAM)hBmpNormal);
// subclass buttons
wpOrigButtonProc = (WNDPROC) SetWindowLong(hWndBtn1,
GWLP_WNDPROC, (LONG) NewButtonProc);
/* same original btn proc */ SetWindowLong(hWndBtn2,
GWLP_WNDPROC, (LONG) NewButtonProc);
// in WM_CLOSE of main dialog procedure
SetWindowLong(hWndBtn1, GWLP_WNDPROC, (LONG)wpOrigButtonProc);
SetWindowLong(hWndBtn2, GWLP_WNDPROC, (LONG)wpOrigButtonProc);
// NewButtonProc window procedure
LRESULT CALLBACK NewButtonProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_MOUSEMOVE:
{
if (!bMouseInWindow)
{
bMouseInWindow = true;
SendMessage(hWnd, BM_SETIMAGE,
(WPARAM)IMAGE_BITMAP, (LPARAM)hBmpHiLight );
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hWnd;
TrackMouseEvent(&tme);
}
}
break;
case WM_MOUSELEAVE:
{
bMouseInWindow = false;
SendMessage(hWnd, BM_SETIMAGE,
(WPARAM)IMAGE_BITMAP, (LPARAM)hBmpNormal);
}
break;
default:
return CallWindowProc(wpOrigButtonProc, hWnd,
uMsg, wParam, lParam);
}
return true;
}
|
|