Control Focus 
Author Message
 Control Focus

Other than setting the focus to another control when a control is clicked, is
there a way to not get the focus rectangle to show on a control?
e.g. when an OptionButton is clicked it is depressed and a focus rectangle
is displayed.
I do not want the focus rectangle so I set the focus on another control,
typically a picturebox that holds the OptionButtons.
So, sometimes this forces me to include a pcturebox when I really have no
need for it.
VB6


Fri, 04 Nov 2011 01:00:11 GMT  
 Control Focus

Quote:
> Other than setting the focus to another control when a control is clicked,
> is
> there a way to not get the focus rectangle to show on a control?
> e.g. when an OptionButton is clicked it is depressed and a focus rectangle
> is displayed.
> I do not want the focus rectangle so I set the focus on another control,
> typically a picturebox that holds the OptionButtons.
> So, sometimes this forces me to include a pcturebox when I really have no
> need for it.
> VB6

Try sending BM_SETSTATE to the button.


Fri, 04 Nov 2011 01:45:07 GMT  
 Control Focus

Quote:
> Other than setting the focus to another control when a control
> is clicked, is there a way to not get the focus rectangle to show
> on a control?

Personally I prefer the method of seting focus to another control, such as a
PictureBox, but if you would prefer not to do that then one alternative is
to send a KillFocus message:

Option Explicit
Private Declare Function SendMessage Lib "user32" _
  Alias "SendMessageA" (ByVal hwnd As Long, _
  ByVal wMsg As Long, ByVal wParam As Long, _
  lParam As Any) As Long
Private Const WM_KILLFOCUS = &H8

Private Sub Option1_Click()
SendMessage Option1.hwnd, WM_KILLFOCUS, 0&, ByVal 0&
End Sub

You may also want to set Tabstop to False on the complete set of Option
Buttons, or otherwise add code to get rid of the focus rectangle if the user
Tabs to an Option Button.

Mike



Fri, 04 Nov 2011 03:48:17 GMT  
 Control Focus


Quote:
> Other than setting the focus to another control when a control is clicked,
> is
> there a way to not get the focus rectangle to show on a control?
> e.g. when an OptionButton is clicked it is depressed and a focus rectangle
> is displayed.
> I do not want the focus rectangle so I set the focus on another control,
> typically a picturebox that holds the OptionButtons.
> So, sometimes this forces me to include a pcturebox when I really have no
> need for it.

The focus rectangle serves an important purpose....to let the user know what
control currently has focus. This is especially important for users that are
navigating by using the keyboard or some means other than the mouse.
Therefore, it's usually not a good idea to "hide" the focus rectangle. If
you're the only one using the app, then I guess that's your prerogative,
But if this app is being used by others, this is not something that I, for
one, would recommend you do.

But to answer your question, no, I don't think there is.  A search at
www.google.com (which you could have done yourself), did not turn any up
anything other than what you're already doing.  I suppose there might very
well be an API function or some other way (subclassing perhaps), but setting
focus to another control was the only answer I managed to find (granted, I
didn't not check ALL hits that were found, only the first few).

--
Mike



Fri, 04 Nov 2011 06:16:52 GMT  
 Control Focus
Focus Rect is Turned Off by default OS installation. unsless Turned On by
user.


Fri, 04 Nov 2011 13:07:33 GMT  
 Control Focus
Thanks for the helpful suggestions.
Quote:

> Other than setting the focus to another control when a control is clicked, is
> there a way to not get the focus rectangle to show on a control?
> e.g. when an OptionButton is clicked it is depressed and a focus rectangle
> is displayed.
> I do not want the focus rectangle so I set the focus on another control,
> typically a picturebox that holds the OptionButtons.
> So, sometimes this forces me to include a pcturebox when I really have no
> need for it.
> VB6



Sat, 05 Nov 2011 01:43:18 GMT  
 Control Focus

Quote:
> Focus Rect is Turned Off by default OS installation. unsless Turned On by
> user.

What in the hell are you talking about?


Sat, 05 Nov 2011 04:46:26 GMT  
 Control Focus
desktop properties > Appearance > Effects > Hide underlined lettter for
keyboard navigation until i press the alt key

If this checkbox is checked, Focus Rect wont draw. and its checked by
default.



|
| > Focus Rect is Turned Off by default OS installation. unsless Turned On
by
| > user.
|
| What in the hell are you talking about?
|
|



Sat, 05 Nov 2011 07:33:11 GMT  
 Control Focus

Quote:
> desktop properties > Appearance > Effects > Hide underlined
> lettter for keyboard navigation until i press the alt key. If this
> checkbox is checked, Focus Rect wont draw. and its checked
> by default.

I think you're talking about a different focus rectangle than the OP, who
was actually asking about the "dotted line" focus rectangle that is drawn
around the text portion of various controls on the Form when the user
selects them using the mouse, such as the focus rectangle around the Caption
text of a command Button or an Option Button.

Mike



Sat, 05 Nov 2011 14:56:57 GMT  
 Control Focus

Tue, 19 May 2009 05:03:11 +0530 bearing the following fruit:

Quote:
>desktop properties > Appearance > Effects > Hide underlined lettter for
>keyboard navigation until i press the alt key

>If this checkbox is checked, Focus Rect wont draw. and its checked by
>default.

The 'underlined letter' won't but this has nothing to do
with the fouces rect.

J

Quote:





>|
>| > Focus Rect is Turned Off by default OS installation. unsless Turned On
>by
>| > user.
>|
>| What in the hell are you talking about?
>|
>|

--
Jan Hyde


Sat, 05 Nov 2011 18:57:48 GMT  
 Control Focus

Quote:
> desktop properties > Appearance > Effects > Hide underlined lettter for
> keyboard navigation until i press the alt key

> If this checkbox is checked, Focus Rect wont draw. and its checked by
> default.

This is not a focus rectangle, it is a "mnemonic."


Sat, 05 Nov 2011 21:41:32 GMT  
 Control Focus


Quote:


>> desktop properties > Appearance > Effects > Hide underlined lettter for
>> keyboard navigation until i press the alt key

>> If this checkbox is checked, Focus Rect wont draw. and its checked by
>> default.

> This is not a focus rectangle, it is a "mnemonic."

I know VB refers to it as a mnemonic but that's a really bad name for it;
they help you get to a specific control quickly via the keyboard but they
don't really help you remember anything...

Calling them "accelerator keys" at least makes some sense.  Either way, they
definitely have nothing to do with focus rectangles.



Sat, 05 Nov 2011 22:02:24 GMT  
 Control Focus

Quote:

> Tue, 19 May 2009 05:03:11 +0530 bearing the following fruit:

>>desktop properties > Appearance > Effects > Hide underlined lettter for
>>keyboard navigation until i press the alt key

>>If this checkbox is checked, Focus Rect wont draw. and its checked by
>>default.

> The 'underlined letter' won't but this has nothing to do
> with the fouces rect.

Despite it's name, this property controls *both* the accelerator (underline)
and focus rectangle. However it is broken in vb (forms). With the property
enabled, a non-themed app will display both, while a themed app will display
neither. And, pressing 'Alt' or other keyboard navigation keys will not
change the state as it should. Msgboxes however, and other windows dialogs,
do follow the property as expected.

David



Sun, 06 Nov 2011 11:10:25 GMT  
 Control Focus

released on Tue, 19 May 2009 22:10:25 -0500 bearing the
following fruit:

Quote:



>> Tue, 19 May 2009 05:03:11 +0530 bearing the following fruit:

>>>desktop properties > Appearance > Effects > Hide underlined lettter for
>>>keyboard navigation until i press the alt key

>>>If this checkbox is checked, Focus Rect wont draw. and its checked by
>>>default.

>> The 'underlined letter' won't but this has nothing to do
>> with the fouces rect.

>Despite it's name, this property controls *both* the accelerator (underline)
>and focus rectangle. However it is broken in vb (forms). With the property
>enabled, a non-themed app will display both, while a themed app will display
>neither. And, pressing 'Alt' or other keyboard navigation keys will not
>change the state as it should. Msgboxes however, and other windows dialogs,
>do follow the property as expected.

>David

It's not an option I would ever choose to have switched on,
but if you're telling me that with it switched on I'd be
unable to tell a button has focus then it sounds worse than
I imagined.

--
Jan Hyde



Sun, 06 Nov 2011 19:33:14 GMT  
 Control Focus

Quote:
>>>desktop properties > Appearance > Effects > Hide underlined lettter for
>>>keyboard navigation until i press the alt key

>>>If this checkbox is checked, Focus Rect wont draw. and its checked by
>>>default.

>> The 'underlined letter' won't but this has nothing to do
>> with the fouces rect.

> Despite it's name, this property controls *both* the accelerator
> (underline) and focus rectangle.

That is absolutely, positively, 100% wrong. It would have taken you seconds
to test, as it did me. The check box does EXACTLY what it says and nothing
more.


Sun, 06 Nov 2011 22:03:38 GMT  
 
 [ 21 post ]  Go to page: [1] [2]

 Relevant Pages 

1. control focus ms access 97

2. Textbox control focus...

3. Dumb question... WebForm control focus

4. strange behavior of control.focus() funktion. Need Help

5. Control.Focus( )

6. control focus in ms access 97

7. Control Focus

8. control focus

9. Control Focus

10. Control Focus Tricks, Help! :-)

11. Storing last control focus ?

12. Active-X-Control Focus Problems

 

 
Powered by phpBB® Forum Software