Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Focus Issue

Status
Not open for further replies.

FireFett

Programmer
Mar 31, 2000
42
US
I am having some problems with a mdi app that has two children side by side one is a 3dRenderview port and has code that when the mouse is over it to primary loop checks the 3dInput object for key input. (This part works fine) the second window(additional windows) are property windows for setting up rendering options/and textures ect.

My problem is this when I move my mouse over the render window I set focus to that form in an attempt to keep the focus kept on Render window but instead what happens is any keypress event gets passed back to the other window subsiquently shift focus back to the other open window.

I have tried using a keypreview turned on in the render window and placed a set focus back to the render window in the render windows keypress event. But thats not working.

Anyone have any suggestions?
 
<when I move my mouse over the render window I set focus to that form in an attempt to keep the focus kept on Render window but instead what happens is any keypress event gets passed back to the other window subsiquently shift focus back to the other open window.

This is a little bit confusing, like trying to stuff one's entire dinner in one's mouth in one go. Although there are those who would say that my mouth is big enough to accommodate such and more, perhaps we can break this down a bit just the same. Let's see if this is what you mean:

1. When you move your mouse over child B, you want child B to become the active window.
2. When you use frmChildB.SetFocus, Child A still receives KeyPress events that you want Child B to receive.
3. Furthermore, every time you press a key, not only does Child A receive the event, but focus passes to child A.

I put together a test that implements the above in a bare-bones fashion, and I'm unable to duplicate this behavior. Assuming that's what you're trying to say, can you post the "render" window's Keypress event code? The problem appears to begin there.

HTH

Bob
 
Yes the steps you outlined are infact what is happening here is the code I have on the Renderwindow


'SET WINDOW POSITION
Me.Left = pfrmWorkspace.Width - (Me.Width + 12)
Me.Top = 0

'SET ENGINES DISPLAY VIEW PORT
pobjEngine.Init3DWindowedMode(picViewPort.Handle.ToInt32)

'GET ENGINE VIDIEO MODE SETTINGS
pobjEngine.GetVideoMode(plngEWidth, plngEHeight, plngEFormat)

End Sub


Private Sub picViewPort_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles picViewPort.MouseHover

'SET MOUSE OVER CAMERA WINDOW FLAG
pbolMouseOverCameraWindow = True
pfrmCamera.Focus()
End Sub

Private Sub picViewPort_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles picViewPort.MouseLeave

'SET MOUSE OVER CAMERA WINDOW FLAG
pbolMouseOverCameraWindow = False

End Sub

Private Sub frmCamera_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
pfrmCamera.Focus()
End Sub

 
Sorry realized that all the code did not make it down

Private Sub frmCamera_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'SET WINDOW POSITION
Me.Left = pfrmWorkspace.Width - (Me.Width + 12)
Me.Top = 0

'SET ENGINES DISPLAY VIEW PORT
pobjEngine.Init3DWindowedMode(picViewPort.Handle.ToInt32)

'GET ENGINE VIDIEO MODE SETTINGS
pobjEngine.GetVideoMode(plngEWidth, plngEHeight, plngEFormat)

End Sub


Private Sub picViewPort_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles picViewPort.MouseHover

'SET MOUSE OVER CAMERA WINDOW FLAG
pbolMouseOverCameraWindow = True
pfrmCamera.Focus()
End Sub

Private Sub picViewPort_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles picViewPort.MouseLeave

'SET MOUSE OVER CAMERA WINDOW FLAG
pbolMouseOverCameraWindow = False

End Sub

Private Sub frmCamera_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
pfrmCamera.Focus()
End Sub
 
I have to apologize. I forgot where I was when I posted that! I thought I was in the VB6 window, and I'm out of my element here. However, perhaps I was able to clarify the problem for someone else.

Bob
 
No problem bob.

I have done the project in VB 6 and this issue doesn't happen it appears to be something new in the .Net framework in the Forms Class that is causing the problem. I will adventually get to the bottom of it.
 
i think you could try to e.cancel the keypress.

Christiaan Baes
Belgium

I just like this --> [Wiggle] [Wiggle]
 
There is no cancel for the keypress that I could find.

But think I might write a larege generic function that when the render window gets focus all controls on anyother midi get disabled and on lost focus re-enabled. :S not exactly what I wanted but should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top