bonnseye
asked on
Changing Bitmaps Drawn Over An Ownerdraw Push Button On/Off On Mouse Hover..
Hi All,
Here comes the same stuff again.. no dialog-box nothing, just a main window, ghwndApp, created with CreateWindowEx(......), on the top of it one command button created like,
HWND hwndcommand1=CreateWindow( "BUTTON",N ULL,WS_VIS IBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_PUSHBUTTON | BS_BITMAP | BS_OWNERDRAW | BS_FLAT,600,320,169,48,ghw ndApp,NULL ,(HINSTANC E)GetWindo wLong(ghwn dApp,GWL_H INSTANCE), NULL);
It's a Ownerdraw, bitmap button, I used WM_DRAWITEM Message To Paint the Button with the HBITMAP bitmap1 (already loaded).
All works fine.
Now what I want more is to change the bitmap over the button to a different picture (that bitmap also loaded) when the mouse is over the button and back to the old bitmap when the mouse is not.
For that I guess, I have to _TrackMouseEvent() for this command button window, hwndcommand1
I did the same just after creating the button as::
TRACKMOUSEEVENT track1;
track1.cbSize=sizeof(TRACK MOUSEEVENT );
track1.dwFlags=TME_HOVER | TME_QUERY;
track1.hwndTrack=(HWND)hwn dcommand1;
track1.dwHoverTime=HOVER_D EFAULT;
_TrackMouseEvent(&track1);
But I am not getting any sort of WM_MOUSEHOVER, when I move mouse over this button.
How can we achieve this kind of stuff, please show some guidelines. To change bitmaps over a button, one while normal and one while the mouse is over it.
Thank You.
Regards,
Bonns
Here comes the same stuff again.. no dialog-box nothing, just a main window, ghwndApp, created with CreateWindowEx(......), on the top of it one command button created like,
HWND hwndcommand1=CreateWindow(
It's a Ownerdraw, bitmap button, I used WM_DRAWITEM Message To Paint the Button with the HBITMAP bitmap1 (already loaded).
All works fine.
Now what I want more is to change the bitmap over the button to a different picture (that bitmap also loaded) when the mouse is over the button and back to the old bitmap when the mouse is not.
For that I guess, I have to _TrackMouseEvent() for this command button window, hwndcommand1
I did the same just after creating the button as::
TRACKMOUSEEVENT track1;
track1.cbSize=sizeof(TRACK
track1.dwFlags=TME_HOVER | TME_QUERY;
track1.hwndTrack=(HWND)hwn
track1.dwHoverTime=HOVER_D
_TrackMouseEvent(&track1);
But I am not getting any sort of WM_MOUSEHOVER, when I move mouse over this button.
How can we achieve this kind of stuff, please show some guidelines. To change bitmaps over a button, one while normal and one while the mouse is over it.
Thank You.
Regards,
Bonns
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks joghurt and AlexFM
joghurt, it is not called even once, there is one message box already over there,
Yes MSDN says that you should call TrackMouseEvent() again for further tracking after wm_mousehover is called, but since it is not called even once after issuing TrackMouseEvent, so this I guess is not the case.
To redraw I intent to use InvalidateRect(), but here even wm_mousehover is not called....
AlexFM, let me see your method. Will get back soon.
Regards,
Bonns
joghurt, it is not called even once, there is one message box already over there,
Yes MSDN says that you should call TrackMouseEvent() again for further tracking after wm_mousehover is called, but since it is not called even once after issuing TrackMouseEvent, so this I guess is not the case.
To redraw I intent to use InvalidateRect(), but here even wm_mousehover is not called....
AlexFM, let me see your method. Will get back soon.
Regards,
Bonns
Probably you may include a bit more of your source.
- "Hover tracking stops when WM_MOUSEHOVER is generated. The application must call TrackMouseEvent again if it requires further tracking of mouse hover behavior." [from MSDN]
- How do you change the bitmap? Do you call Invalidate so that the button gets redrawn?