Print Page | Close Window

Remove focus rect from button

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Suite Pro
Forum Description: Topics Related to Codejock Suite Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=9712
Printed Date: 07 May 2024 at 2:05am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Remove focus rect from button
Posted By: JantjeKeizer
Subject: Remove focus rect from button
Date 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.



Replies:
Posted By: nighthawk
Date Posted: 02 March 2008 at 7:21am
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.


Posted By: Jebo
Date Posted: 29 March 2008 at 12:14pm
@Codejock-team
Is there a "DrawFocusRect"-Property in the next release?
 
Because I've the same problem and the focus rectangle is realy nasty!


Posted By: corpcon
Date Posted: 29 March 2008 at 1:43pm
nighthawk's solution is simple and is what has been used by developers for more than the past decade.


Posted By: Jebo
Date Posted: 29 March 2008 at 1:52pm
@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!!!


Posted By: Oleg
Date Posted: 31 March 2008 at 1:20am
Hi,
 
DrawFocusRect property added for 12.0 release


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net