By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,478 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Testing for focus on a form

P: n/a
I want to be able to test if my app's form has focus, (ie: not in
background, behind other windows). How can I do this? I tried the
Me.Focused, but that doesn't work. I think it's because a control
within the form actually has focus, so the Me.Focused would return
false. Thanks!
Nov 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
try ContainsFocus property

dominique

"copyco" <co****@anon.com> wrote in message
news:fn********************@newssvr11.news.prodigy .com...
I want to be able to test if my app's form has focus, (ie: not in
background, behind other windows). How can I do this? I tried the
Me.Focused, but that doesn't work. I think it's because a control
within the form actually has focus, so the Me.Focused would return
false. Thanks!

Nov 20 '05 #2

P: n/a
Sounds good, but I don't seem to have that property. It doesn't come up
in the help search either. This is a Windows App, not a Web App.
Perhaps there's a difference.

Dominique Vandensteen wrote:
try ContainsFocus property

dominique

"copyco" <co****@anon.com> wrote in message
news:fn********************@newssvr11.news.prodigy .com...
I want to be able to test if my app's form has focus, (ie: not in
background, behind other windows). How can I do this? I tried the
Me.Focused, but that doesn't work. I think it's because a control
within the form actually has focus, so the Me.Focused would return
false. Thanks!


Nov 20 '05 #3

P: n/a
it's a property of System.Windows.Form.Control which is one of the base
classes of Form...


.NET Framework Class Library

Control.ContainsFocus Property
See Also
Control Class | Control Members | System.Windows.Forms Namespace | CanFocus
| Focus | Focused | CanSelect

Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows
2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server
family

Language
a.. C#

b.. C++

c.. JScript

d.. Visual Basic

e.. Show All
Gets a value indicating whether the control, or one of its child controls,
currently has the input focus.

[Visual Basic]
Public ReadOnly Property ContainsFocus As Boolean[C#]
public bool ContainsFocus {get;}[C++]
public: __property bool get_ContainsFocus();[JScript]
public function get ContainsFocus() : Boolean;Property Value
true if the control or one of its child controls currently has the input
focus; otherwise, false.

Remarks
You can use this property to determine whether a control or any of the
controls contained within it has the input focus. To determine whether the
control has focus, regardless of whether any of its child controls have
focus, use the Focused property. To give a control the input focus, use the
Focus or Select methods.

Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows
2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server
family

See Also
Control Class | Control Members | System.Windows.Forms Namespace | CanFocus
| Focus | Focused | CanSelect
----------------------------------------------------------------------------
----

Send comments on this topic.

2001 Microsoft Corporation. All rights reserved.

"copyco" <co****@anon.com> wrote in message
news:lF**************@newssvr22.news.prodigy.com.. .
Sounds good, but I don't seem to have that property. It doesn't come up
in the help search either. This is a Windows App, not a Web App.
Perhaps there's a difference.

Dominique Vandensteen wrote:
try ContainsFocus property

dominique

"copyco" <co****@anon.com> wrote in message
news:fn********************@newssvr11.news.prodigy .com...
I want to be able to test if my app's form has focus, (ie: not in
background, behind other windows). How can I do this? I tried the
Me.Focused, but that doesn't work. I think it's because a control
within the form actually has focus, so the Me.Focused would return
false. Thanks!


Nov 20 '05 #4

P: n/a
Is there some sort of Imports that I need to include in my project to
get this property? When I type Me. ContainsFocus is not available.

Dominique Vandensteen wrote:
it's a property of System.Windows.Form.Control which is one of the base
classes of Form...


.NET Framework Class Library

Control.ContainsFocus Property
See Also
Control Class | Control Members | System.Windows.Forms Namespace | CanFocus
| Focus | Focused | CanSelect

Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows
2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server
family

Language
a.. C#

b.. C++

c.. JScript

d.. Visual Basic

e.. Show All
Gets a value indicating whether the control, or one of its child controls,
currently has the input focus.

[Visual Basic]
Public ReadOnly Property ContainsFocus As Boolean[C#]
public bool ContainsFocus {get;}[C++]
public: __property bool get_ContainsFocus();[JScript]
public function get ContainsFocus() : Boolean;Property Value
true if the control or one of its child controls currently has the input
focus; otherwise, false.

Remarks
You can use this property to determine whether a control or any of the
controls contained within it has the input focus. To determine whether the
control has focus, regardless of whether any of its child controls have
focus, use the Focused property. To give a control the input focus, use the
Focus or Select methods.

Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows
2000, Windows XP Home Edition, Windows XP Professional, Windows .NET Server
family

See Also
Control Class | Control Members | System.Windows.Forms Namespace | CanFocus
| Focus | Focused | CanSelect
----------------------------------------------------------------------------
----

Send comments on this topic.

2001 Microsoft Corporation. All rights reserved.

"copyco" <co****@anon.com> wrote in message
news:lF**************@newssvr22.news.prodigy.com.. .
Sounds good, but I don't seem to have that property. It doesn't come up
in the help search either. This is a Windows App, not a Web App.
Perhaps there's a difference.

Dominique Vandensteen wrote:

try ContainsFocus property

dominique

"copyco" <co****@anon.com> wrote in message
news:fn********************@newssvr11.news.prod igy.com...
I want to be able to test if my app's form has focus, (ie: not in
background, behind other windows). How can I do this? I tried the
Me.Focused, but that doesn't work. I think it's because a control
within the form actually has focus, so the Me.Focused would return
false. Thanks!


Nov 20 '05 #5

P: n/a
Ah, nevermind. It isn't available via intelli-sense. You have to type
it in manually. How strange. Thanks for the help.

copyco wrote:
Is there some sort of Imports that I need to include in my project to
get this property? When I type Me. ContainsFocus is not available.

Dominique Vandensteen wrote:
it's a property of System.Windows.Form.Control which is one of the base
classes of Form...


.NET Framework Class Library

Control.ContainsFocus Property
See Also
Control Class | Control Members | System.Windows.Forms Namespace |
CanFocus
| Focus | Focused | CanSelect

Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition,
Windows
2000, Windows XP Home Edition, Windows XP Professional, Windows .NET
Server
family

Language
a.. C#

b.. C++

c.. JScript

d.. Visual Basic

e.. Show All
Gets a value indicating whether the control, or one of its child
controls,
currently has the input focus.

[Visual Basic]
Public ReadOnly Property ContainsFocus As Boolean[C#]
public bool ContainsFocus {get;}[C++]
public: __property bool get_ContainsFocus();[JScript]
public function get ContainsFocus() : Boolean;Property Value
true if the control or one of its child controls currently has the input
focus; otherwise, false.

Remarks
You can use this property to determine whether a control or any of the
controls contained within it has the input focus. To determine whether
the
control has focus, regardless of whether any of its child controls have
focus, use the Focused property. To give a control the input focus,
use the
Focus or Select methods.

Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition,
Windows
2000, Windows XP Home Edition, Windows XP Professional, Windows .NET
Server
family

See Also
Control Class | Control Members | System.Windows.Forms Namespace |
CanFocus
| Focus | Focused | CanSelect
----------------------------------------------------------------------------

----

Send comments on this topic.

2001 Microsoft Corporation. All rights reserved.

"copyco" <co****@anon.com> wrote in message
news:lF**************@newssvr22.news.prodigy.com.. .
Sounds good, but I don't seem to have that property. It doesn't come up
in the help search either. This is a Windows App, not a Web App.
Perhaps there's a difference.

Dominique Vandensteen wrote:
try ContainsFocus property

dominique

"copyco" <co****@anon.com> wrote in message
news:fn********************@newssvr11.news.prodigy .com...
> I want to be able to test if my app's form has focus, (ie: not in
> background, behind other windows). How can I do this? I tried the
> Me.Focused, but that doesn't work. I think it's because a control
> within the form actually has focus, so the Me.Focused would return
> false. Thanks!


Nov 20 '05 #6

P: n/a
* copyco <co****@anon.com> scripsit:
Ah, nevermind. It isn't available via intelli-sense. You have to
type it in manually. How strange. Thanks for the help.


Are you sure you enabled the option to show advanced members in the
IDE's settings?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

P: n/a
Nope, I sure haven't. Where is this setting?
Herfried K. Wagner [MVP] wrote:
* copyco <co****@anon.com> scripsit:
Ah, nevermind. It isn't available via intelli-sense. You have to
type it in manually. How strange. Thanks for the help.

Are you sure you enabled the option to show advanced members in the
IDE's settings?

Nov 20 '05 #8

P: n/a
* copyco <co****@anon.com> scripsit:
Nope, I sure haven't. Where is this setting?


I am not sure if it will help in this case.

You can show advanced members in the code editor with the "Hide advanced
members" option under "Tools" -> "Options" -> "Text Editor" -> "Basic"
-> "General".

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.