Remove focus rect from button |
Post Reply |
Author | |
JantjeKeizer
Groupie Joined: 12 February 2008 Status: Offline Points: 70 |
Post Options
Thanks(0)
Posted: 27 February 2008 at 5:26am |
Is it possible to remove the focus rect from a pushbutton?
We have an application that uses some small flatstyle buttons with just a 16 pixel image inside. When the button gains focus, the rectangle is drawn inside the small button temporarily 'destroying' the image. I've tried to subclass the button to eat the WM_SETFOCUS message. Whilst this works for vb6's native commandbutton, it doesn't seem to be working on the pushbutton. |
|
nighthawk
Senior Member Joined: 11 June 2004 Status: Offline Points: 167 |
Post Options
Thanks(0)
|
I've ran into the same situation with other controls where I don't want it to show a focus rectangle. My solution is to manually move the focus to another control. So, at the end of the click event, have a line such as:
Button1.SetFocus You can send the focus to any control that has a "SetFocus" method. If there aren't any that you want to get focus, create one and move it off-screen so it is never seen. I don't think it would work to set it to be invisible because I seem to recall that you can't give focus to an invisible control. |
|
Jebo
Senior Member Joined: 27 October 2005 Location: Germany Status: Offline Points: 318 |
Post Options
Thanks(0)
|
@Codejock-team
Is there a "DrawFocusRect"-Property in the next release?
Because I've the same problem and the focus rectangle is realy nasty!
|
|
corpcon
Groupie Joined: 28 June 2007 Status: Offline Points: 70 |
Post Options
Thanks(0)
|
nighthawk's solution is simple and is what has been used by developers for more than the past decade.
|
|
Jebo
Senior Member Joined: 27 October 2005 Location: Germany Status: Offline Points: 318 |
Post Options
Thanks(0)
|
@corporn
no this is no solution it is only a workaround.
Because I can't use taborders for my customers. If the user press <Tab> to jump to the next control on form he'll always jump to a special control (what ever one). This "solution" I used before some years - and it is realy bad - the result is a uncontrolled GUI and much more code (U must check if the destination-control is enabled OR U must use "On Error Resume Next" *uaaaa*)
And by the way: nighthawk's "solution" works only, if the user "Click" the button!!! If the user focus the button on another way (like TAB-press) U need code for "On_Focus Event" too!!!
|
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
DrawFocusRect property added for 12.0 release
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |