Home All Groups Group Topic Archive Search About
Author
17 May 2009 5:00 PM
Bee
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

Author
17 May 2009 5:45 PM
Nobody
"Bee" <B**@discussions.microsoft.com> wrote in message
news:7703D74E-5E41-4D86-AA4F-8EACBE650743@microsoft.com...
> 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.
Author
17 May 2009 7:48 PM
Michael Williams
"Bee" <B**@discussions.microsoft.com> wrote in message
news:7703D74E-5E41-4D86-AA4F-8EACBE650743@microsoft.com...

> 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
Author
17 May 2009 10:16 PM
MikeD
"Bee" <B**@discussions.microsoft.com> wrote in message
news:7703D74E-5E41-4D86-AA4F-8EACBE650743@microsoft.com...
> 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
Author
18 May 2009 5:07 AM
Abhishek
Focus Rect is Turned Off by default OS installation. unsless Turned On by
user.
Author
18 May 2009 8:46 PM
Jeff Johnson
"Abhishek" <m*@server.com> wrote in message
news:OLTKOa31JHA.3676@TK2MSFTNGP06.phx.gbl...

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

What in the hell are you talking about?
Author
18 May 2009 11:33 PM
Abhishek
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.


Show quoteHide quote
"Jeff Johnson" <i.get@enough.spam> wrote in message
news:Ob0n3m$1JHA.5772@TK2MSFTNGP02.phx.gbl...
| "Abhishek" <m*@server.com> wrote in message
| news:OLTKOa31JHA.3676@TK2MSFTNGP06.phx.gbl...
|
| > Focus Rect is Turned Off by default OS installation. unsless Turned On
by
| > user.
|
| What in the hell are you talking about?
|
|
Author
19 May 2009 6:56 AM
Mike Williams
"Abhishek" <m*@server.com> wrote in message
news:e7jdCEB2JHA.1712@TK2MSFTNGP03.phx.gbl...

> 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
Author
19 May 2009 10:57 AM
Jan Hyde
"Abhishek" <m*@server.com>'s wild thoughts were released on
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.

J

Show quoteHide quote
>
>"Jeff Johnson" <i.get@enough.spam> wrote in message
>news:Ob0n3m$1JHA.5772@TK2MSFTNGP02.phx.gbl...
>| "Abhishek" <m*@server.com> wrote in message
>| news:OLTKOa31JHA.3676@TK2MSFTNGP06.phx.gbl...
>|
>| > Focus Rect is Turned Off by default OS installation. unsless Turned On
>by
>| > user.
>|
>| What in the hell are you talking about?
>|
>|
>

--
Jan Hyde
Author
20 May 2009 3:10 AM
David Youngblood
"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
news:h44515hr58n9i5ash9r67etonmefrk9la1@4ax.com...
> "Abhishek" <m*@server.com>'s wild thoughts were released on
> 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
Author
20 May 2009 11:33 AM
Jan Hyde
"David Youngblood" <d**@flash.net>'s wild thoughts were
released on Tue, 19 May 2009 22:10:25 -0500 bearing the
following fruit:

Show quoteHide quote
>"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
>news:h44515hr58n9i5ash9r67etonmefrk9la1@4ax.com...
>> "Abhishek" <m*@server.com>'s wild thoughts were released on
>> 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
Author
20 May 2009 2:03 PM
Jeff Johnson
Show quote Hide quote
"David Youngblood" <d**@flash.net> wrote in message
news:uOtEgiP2JHA.4416@TK2MSFTNGP05.phx.gbl...

>>>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.
Author
20 May 2009 4:36 PM
David Youngblood
Show quote Hide quote
"Jeff Johnson" <i.get@enough.spam> wrote in message
news:%23Ek3GPV2JHA.3544@TK2MSFTNGP04.phx.gbl...
> "David Youngblood" <d**@flash.net> wrote in message
> news:uOtEgiP2JHA.4416@TK2MSFTNGP05.phx.gbl...
>
>>>>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.

I can only suggest that you spend a little more than a few seconds testing,
I have.
Try this in XP,
    Open the Display Properties Effects page
    Set focus to the 'Hide underlined letters...' checkbox  (heading may
differ among OS's)
    Press F1 and read the help text for this property (copy/pasted below)

"Specifies whether to suppress the drawing of keyboard shortcuts (the
underlined characters in menus and controls) and input focus indicators (the
dotted rectangles around objects), until you actually start using the
keyboard to navigate in Windows, generally with the ALT, TAB, or arrow
keys."

While you were there did you notice that if the property was enabled that
there is *no* focus rectangle displayed until you press one of the keyboard
navigation keys? Try it.

I as said earlier, this *feature* does not function properly in VB and it's
behavior is different between themed and non-themed VB applications.

I have posted code in the past to override this property and I'll post it
again here.

Option Explicit

Private Const WM_CHANGEUISTATE As Long = &H127
Private Const UISF_HIDEFOCUS As Integer = &H1
Private Const UISF_HIDEACCEL As Integer = &H2
Private Const UIS_CLEAR As Integer = &H2

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 Sub Form_Load()
    Dim uiState As Long
    uiState = MakeLong(UIS_CLEAR, UISF_HIDEFOCUS Or UISF_HIDEACCEL)
    SendMessage Me.hwnd, WM_CHANGEUISTATE, uiState, ByVal 0
End Sub

Private Function MakeLong(ByVal wLow As Integer, ByVal wHigh As Integer) As
Long
    MakeLong = wHigh * &H10000 + wLow
End Function

David
Author
20 May 2009 8:43 PM
Jeff Johnson
"David Youngblood" <d**@flash.net> wrote in message
news:O99xGlW2JHA.4412@TK2MSFTNGP06.phx.gbl...

> "Specifies whether to suppress the drawing of keyboard shortcuts (the
> underlined characters in menus and controls) and input focus indicators
> (the dotted rectangles around objects), until you actually start using the
> keyboard to navigate in Windows, generally with the ALT, TAB, or arrow
> keys."

Ahhhh, that's a much clearer explanation, thank you. I didn't understand
what you meant at first when you said "navigation keys"; I thought you just
meant menu navigation keys, i.e., Alt & F10.

And now that I see it in action, I think it's utterly horrible. It's bad
enough that they turned off the underlines to begin with, but ALL focus
indicators? Yuck.
Author
21 May 2009 6:42 PM
RonW
On Wed, 20 May 2009 16:43:24 -0400, "Jeff Johnson" <i.get@enough.spam> wrote:

>And now that I see it in action, I think it's utterly horrible. It's bad
>enough that they turned off the underlines to begin with, but ALL focus
>indicators? Yuck.

Yuck indeed. It seems Microsoft has become so infatuated with the "kewl" factor
in its user interfaces that it has abandoned any thoughts of ~actual~ usability.
I blame it on Microsoft's apparently incurable Mac-envy. Others will, of course,
disagree.

RW
Author
22 May 2009 10:40 AM
Dave O.
Yes it's horrible but it can be fixed.
Call this in the form load:

Public Sub EnableUIFocusMarks(FrmHWnd As Long)
Call SendMessageAny(FrmHWnd, WM_CHANGEUISTATE, USIF_RESETUI, ByVal 0)
End Sub

Declarations:
Private Const WM_CHANGEUISTATE   As Long = &H127
Private Const USIF_RESETUI         As Long = &H30002

Private Declare Function SendMessageAny Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As
Any) As Long

'                            COMMENT
'USIF_RESETUI  =
'             (LoBytes) Const UIS_CLEAR      As Integer = &H2
'     +      (HiBytes) Const UISF_HIDEFOCUS As Integer = &H1
'     +      (HiBytes) Const UISF_HIDEACCEL As Integer = &H2

Dave O.

<RonW@no_domain.invalid> wrote in message
Show quoteHide quote
news:3p7b155umnjt4tado8gpnoh39bnri14sth@4ax.com...
> On Wed, 20 May 2009 16:43:24 -0400, "Jeff Johnson" <i.get@enough.spam>
> wrote:
>
>>And now that I see it in action, I think it's utterly horrible. It's bad
>>enough that they turned off the underlines to begin with, but ALL focus
>>indicators? Yuck.
>
> Yuck indeed. It seems Microsoft has become so infatuated with the "kewl"
> factor
> in its user interfaces that it has abandoned any thoughts of ~actual~
> usability.
> I blame it on Microsoft's apparently incurable Mac-envy. Others will, of
> course,
> disagree.
>
> RW
Author
26 May 2009 4:01 PM
Jeff Johnson
"Dave O." <nob***@nowhere.com> wrote in message
news:%23CdLIns2JHA.5772@TK2MSFTNGP02.phx.gbl...

> Yes it's horrible but it can be fixed.
> Call this in the form load:

As much as I hate it, I hate any program which screws with my user
settings--without asking my permission first--more.
Author
19 May 2009 1:41 PM
Jeff Johnson
"Abhishek" <m*@server.com> wrote in message
news:e7jdCEB2JHA.1712@TK2MSFTNGP03.phx.gbl...

> 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."
Author
19 May 2009 2:02 PM
Bob Butler
"Jeff Johnson" <i.get@enough.spam> wrote in message
news:uHNPGeI2JHA.3812@TK2MSFTNGP05.phx.gbl...
> "Abhishek" <m*@server.com> wrote in message
> news:e7jdCEB2JHA.1712@TK2MSFTNGP03.phx.gbl...
>
>> 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.
Author
18 May 2009 5:43 PM
Bee
Thanks for the helpful suggestions.

Show quoteHide quote
"Bee" wrote:

> 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
>