By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,741 Members | 1,979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,741 IT Pros & Developers. It's quick & easy.

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

P: 3
How can I change the color of button on mouse move over it.
help .
Aug 29 '06 #1
Share this Question
Share on Google+
3 Replies


Banfa
Expert Mod 5K+
P: 8,916
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

P: 3
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
Expert Mod 5K+
P: 8,916
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.