5 Replies - 380 Views - Last Post: 30 January 2013 - 03:14 PM Rate Topic: -----

#1 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Focus Window

Posted 30 January 2013 - 01:01 PM

Hi again, i was thinking on how can i see wich window is focus? Like when open something, know the name of the window, where should i look for it?
Is This A Good Question/Topic? 0
  • +

Replies To: Focus Window

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Focus Window

Posted 30 January 2013 - 01:16 PM

Well, off the top of my head you could look through the My.Application.OpenForms collection and check which one has .Focused = true

There's probably another way, but it was just the first thing I thought of.
Was This Post Helpful? 0
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3467
  • View blog
  • Posts: 11,774
  • Joined: 12-December 12

Re: Focus Window

Posted 30 January 2013 - 01:28 PM

View PostCharlieMay, on 30 January 2013 - 01:16 PM, said:

Well, off the top of my head you could look through the My.Application.OpenForms collection and check which one has .Focused = true

There's probably another way, but it was just the first thing I thought of.

ContainsFocus is probably more reliable :)/>

        For Each frm As Form In Application.OpenForms
            If frm.ContainsFocus Then
                MessageBox.Show(frm.Name)
            End If
        Next

But I would question why you need to do this? Where would you put this code?!

Each form should be self-contained - responsible for its own destiny - so your request should not really be necessary.

Added: We can read the property directly with the shared property ActiveForm:

MessageBox.Show(Form.ActiveForm.Name)

This post has been edited by andrewsw: 30 January 2013 - 01:30 PM

Was This Post Helpful? 0
  • +
  • -

#4 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: Focus Window

Posted 30 January 2013 - 02:09 PM

Thanks for the help, that's useful to know even not what i was looking, i was looking in the window itself, not inside the app.. i found it here http://social.msdn.m...a3-646ab6551f09

Thanks, as i say, that's useful for the future and sorry if i didn't make my question clear.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3467
  • View blog
  • Posts: 11,774
  • Joined: 12-December 12

Re: Focus Window

Posted 30 January 2013 - 02:45 PM

View PostHeBTeMy, on 30 January 2013 - 02:09 PM, said:

Thanks for the help, that's useful to know even not what i was looking, i was looking in the window itself, not inside the app.. i found it here http://social.msdn.m...a3-646ab6551f09

Thanks, as i say, that's useful for the future and sorry if i didn't make my question clear.

Yes, you did refer to window in your opening post :)/>. It's just that most of the time when people refer to window (in .NET) they usually mean form - a form is the window in .NET apps.

No worries. Andy.

This post has been edited by andrewsw: 30 January 2013 - 02:46 PM

Was This Post Helpful? 0
  • +
  • -

#6 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: Focus Window

Posted 30 January 2013 - 03:14 PM

Yeah, i know that : D, i just did not want to type "How i can see the name of the form that is focused on the Windows (OS) not the app one.) or similar, anyway, thanks for the help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1