472,353 Members | 1,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Testing for focus on a form

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
8 1860
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
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
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
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
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
* 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
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
* 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Irwin | last post by:
I'd like to prevent a submit button from getting focus unless a particular textbox or radio button is selected. For example, if a user clicks...
0
by: Jonathan Allen | last post by:
We have found that our method of testing does not match traditional text-book methodologies. I decided to write a short white paper on it so that I...
5
by: tshad | last post by:
I have a date validation function that I want to stay at the object I am validating if there is a Validation error, but it always goes to the next...
17
by: Neil Ginsberg | last post by:
OK, this is a stupid thing, but I can't seem to get this to work. I have a form with a subform (in continuous form view). A combo box on the main...
5
by: Tosch | last post by:
I have a usercontrol with a label, a textbox, a treeview, a grid and a couple of checkboxes. The usercontrol is hosted on a form together with a...
1
by: David | last post by:
Hi, I have a continuous form with 'x' amount of records. 1 field on each record is a number, of which I have a field at the top of the form...
7
by: Ed Jay | last post by:
I'm trying to validate a form's file input elements using javascript, but I'm getting nowhere. How can javascript test if a file has been selected...
18
by: Andrew Wan | last post by:
I have been developing web applications with ASP & Javascript for a long time. I have been using Visual Studio 2003.NET. While VS2003 is okay for...
11
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.