469,917 Members | 1,575 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

A Question of form focus - VB.NET 2003

Is there a way of stopping a form getting focus in VB.NET. The scenario I
have is a main form and a form used for display only. There are no user
controls on the display form and it does not ever need to have the focus.
When the displays on the form are updated it appears to get the focus. I
would like to prevent this because if the user operates any hot-keys
(thinking the main form still has focus) these keys will fail.

I have tried saving the display form's owner in a variable and then
executing the following in my UpdateDisplay method. However the focus
remains with the display form, when I had hoped it would be set to the main
form (the display forms owner).

mOwner.Select()

I have also tried:

mOwner.Focus()

Neither of which seem to work.

Many thanks,
Sid.
Apr 22 '06 #1
2 5215
Sid Price wrote:
Is there a way of stopping a form getting focus in VB.NET. The scenario I
have is a main form and a form used for display only. There are no user
controls on the display form and it does not ever need to have the focus.
When the displays on the form are updated it appears to get the focus. I
would like to prevent this because if the user operates any hot-keys
(thinking the main form still has focus) these keys will fail.

I have tried saving the display form's owner in a variable and then
executing the following in my UpdateDisplay method. However the focus
remains with the display form, when I had hoped it would be set to the main
form (the display forms owner).

mOwner.Select()

I have also tried:

mOwner.Focus()

Neither of which seem to work.

Many thanks,
Sid.


Just because you update some controls on a form it should not get focus.
You may want to show the code that causes the form to get focus.

Chris
Apr 22 '06 #2
"Chris" <no@spam.com> wrote in message
news:uP**************@TK2MSFTNGP05.phx.gbl...
Sid Price wrote:
Is there a way of stopping a form getting focus in VB.NET. The scenario I
have is a main form and a form used for display only. There are no user
controls on the display form and it does not ever need to have the focus.
When the displays on the form are updated it appears to get the focus. I
would like to prevent this because if the user operates any hot-keys
(thinking the main form still has focus) these keys will fail.

I have tried saving the display form's owner in a variable and then
executing the following in my UpdateDisplay method. However the focus
remains with the display form, when I had hoped it would be set to the
main form (the display forms owner).

mOwner.Select()

I have also tried:

mOwner.Focus()

Neither of which seem to work.

Many thanks,
Sid.


Just because you update some controls on a form it should not get focus.
You may want to show the code that causes the form to get focus.

Chris


This is the mothod that updates the controls on the form:

Private Sub UpdateDisplay()

Dim iSeconds As Integer = iValue Mod 60

Dim iMinutes As Integer = iValue \ 60

Dim strDisplay As String

If iSeconds < 10 Then

strDisplay = iMinutes & ":0" & iSeconds

Else

strDisplay = iMinutes & ":" & iSeconds

End If

ledCount.Text = strDisplay

End Sub

Sid.
Apr 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Charles Banas | last post: by
3 posts views Thread by bradwiseathome | last post: by
18 posts views Thread by Charles May | last post: by
4 posts views Thread by easoftware | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.