Click here to Skip to main content
13,050,840 members (58,210 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Experts,
I need to remove the default selection rectangle that will show after a mouse click in MFC. I think this is a default mechanism to idetify which is the last interacted control. I want to remove this selection.Is it possible? Please help me..

Posted 29-May-11 18:23pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

No! There are two states of the button: one shows that the button is default, another state shows if it currently has input focus. If it has input focus, it indicated that it will ask as "click" if you hit blank space. If it is default, it will do it if you hit Enter even if the keyboard focus is somewhere else.

This is very important visual feedback you don't want to remove.

However, if you really want to allow such violation of the common UI style, you can do the following: 1) Add button style BS_OWNERDRAW and perform owner draw at your liking, 2) make a button non-focusable.

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You need to subclass it (click here[^] for a great subclassing article by Chris Maunder)

And within your new button callback, process WM_SETFOCUS[^]
Stephen Wiria 31-May-11 20:09pm
Strange, why downvoted my solution?
I guess either the guy who downvoted me doesn't understand at all (if you want a complete sample, just ask!) or just goofing around. Silly

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 May 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100