473,554 Members | 2,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1997
try ContainsFocus property

dominique

"copyco" <co****@anon.co m> wrote in message
news:fn******** ************@ne wssvr11.news.pr odigy.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.co m> wrote in message
news:fn******** ************@ne wssvr11.news.pr odigy.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.Contain sFocus 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_ContainsFoc us();[JScript]
public function get ContainsFocus() : Boolean;Propert y 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.co m> wrote in message
news:lF******** ******@newssvr2 2.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.co m> wrote in message
news:fn******** ************@ne wssvr11.news.pr odigy.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.Contain sFocus 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_ContainsFoc us();[JScript]
public function get ContainsFocus() : Boolean;Propert y 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.co m> wrote in message
news:lF******** ******@newssvr2 2.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.co m> 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
backgroun d, behind other windows). How can I do this? I tried the
Me.Focuse d, 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.Contain sFocus 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_ContainsFoc us();[JScript]
public function get ContainsFocus() : Boolean;Propert y 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.co m> wrote in message
news:lF******** ******@newssvr2 2.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.co m> wrote in message
news:fn******** ************@ne wssvr11.news.pr odigy.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.co m> 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.co m> 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.co m> 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
5104
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 anywhere within a form, the submit button is focused and will submit whatever data is present if the user accidentally presses Enter/Return. I would like to prevent this from happening unless the...
0
1739
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 could get your opinions. Does anyone else use this method? If so, what the heck is it called? Do you think it would work in other projects, or did we just luck out? Jonathan Allen ...
5
11362
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 object. The Javascript: function ValidateForm(me){ var dt=me if (isDate(dt.value)==false){ dt.focus()
17
3839
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 form has code in the AfterUpdate event which adds a record to the subform (based on the value of the combo box) and requeries the subform control. I want the focus to return to the combo box on the...
5
8701
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 cancel and a accept button. This form is used to search records in a database. On several forms in my application I show (modal) this form to search records. Everytime I show the form I want the...
1
2311
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 which just shows the running sum. If I enter a new record, after I loose focus of the number field, I perform a save record and then test the data with a calculation, but the problem I have is that...
7
4589
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 using a file form input element? -- Ed Jay (remove 'M' to respond by email)
18
2367
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 intellisense of ASP & Javascript, it's still not that great. One of the cons of ASP & Javascript is that they're both interpreted, which means one has twice the amount of work to do interms of...
11
2340
by: VK | last post by:
In the continuation of the discussion at "Making Site Opaque -- This Strategy Feasible?" and my comment at http://groups.google.com/group/comp.lang.javascript/msg/b515a4408680e8e2 I have realized that despite suggestions to use DHTML-based modal dialogs are very common? there is not a single fully functional reliable copyright-free...
0
7578
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8010
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7530
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5414
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
1994
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1111
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.