468,496 Members | 1,776 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,496 developers. It's quick & easy.

How can I change the color of button on mouse move over it

How can I change the color of button on mouse move over it.
help .
Aug 29 '06 #1
3 6948
Banfa
9,055 Expert Mod 8TB
Subclass the button and make it owner drawn and intercept the WM_MOUSEMOVE or WM_MOUSEHOVER events to tell when the mouse is over the button and then draw the button appropriately as required.

Not terribly easy I'd say.
Aug 29 '06 #2
Subclass the button and make it owner drawn and intercept the WM_MOUSEMOVE or WM_MOUSEHOVER events to tell when the mouse is over the button and then draw the button appropriately as required.

Not terribly easy I'd say.

how i intercept the WM_MOUSEMOVE or WM_MOUSEHOVER events.
Aug 30 '06 #3
Banfa
9,055 Expert Mod 8TB
Well that rather depends on the environment you are writing your program in (I have already assumed Windows so ignore this if you are using *nix) straight WIN32 or MFC.

Like a said you need to subclass the button and then add your ownhandlers. This is reasonably easy in MFC your just create a subclass from the CButton class and then add your message handlers to that new class. Then in the class Wizard you have to assign a variable to the Button with a type of CButton and then manually edit the header file for the window to change the class CButton to CMyButton.

In normal windows you need to subclass the button by using GetWindowLong to get the event handler for the button, store that event handler and use SetWindowLong to insert your onw event handler for the button. In your own event handler call the original event handler except for the messages you wish to intercept in order to change the button colour.
Aug 30 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.