Using Windows.Form


17-10-2006 18:23:25

Hi, I'm currently using this wrapper for an editor to our Ogre based game.

I have this upp and running, one form with a panel and a Mogre window inside this panel. The window is split into four viewports.

Now, the only problem I got so far is how do I capture input?

Using Axiom.Input as in the ExampleApplication and using false on ownMouse
(otherwise i get some error in setcooperationLevel)

Now, the only time I actually get some input to my:
protected void HandleInput( FrameEvent evt )
is when I click a button that is placed beside the panel.
(This button is set do do nothing, the button1_click function is completely

Any ideas on how to get it to read the mouse when its over the Mogrewindowarea?


17-10-2006 19:08:48

It's not that hard, in you can do it like this:

Private moving As Boolean = False
Private mouseRButton As Boolean = False
Private mOldX As Integer = 0
Private mOldY As Integer = 0

Private Sub pOgreRenderPanel_MouseWheel(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pOgreRenderPanel.MouseWheel, Me.MouseWheel
If Not mouseRButton Then Vector3(0, 0, e.Delta / 10))
If e.Delta > 0 Then, New Radian(System.Convert.ToSingle(0.01)))
Else, New Radian(System.Convert.ToSingle(-0.01)))
End If
End If

End Sub

Private Sub pOgreRenderPanel_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pOgreRenderPanel.MouseDown
If e.Button = Windows.Forms.MouseButtons.Right Then
mOldX = e.X
mOldY = e.Y
moving = True
mouseRButton = True
End If
End Sub

Private Sub pOgreRenderPanel_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pOgreRenderPanel.MouseUp
If e.Button = Windows.Forms.MouseButtons.Right Then
moving = False
mouseRButton = False
End If
End Sub

Private Sub pOgreRenderPanel_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pOgreRenderPanel.MouseMove
If moving Then
Dim relX As Integer = e.X - mOldX
Dim relY As Integer = e.Y - mOldY
mOldX = e.X
mOldY = e.Y Vector3((relX / 4) * -1, (relY / 4), 0))
End If
End Sub


17-10-2006 19:27:23

Now, the only problem I got so far is how do I capture input?
Don't use Axiom.Input, as rosenkro pointed out, you can use the Windows Forms key and mouse events (MouseMove, KeyUp/Down etc).


17-10-2006 19:57:01

Thanks for the replys, but I've already tried that and as soon as I move the
mouse over the viewports it's as if it goes dead, nothing registers.

I've tried MouseDown, MouseClick, MouseMove on both the panel and the Form itself. As long as i'm outside the viewport it all registers and when I move over it, nothing.

Oh well, I'll continue to investigate, I'm sure its some minor detail I missed somewhere.


17-10-2006 20:22:03

I had the same problem. In the win-forms example there is a line like this:

misc("parentWindowHandle") = ParentHWnd.ToString()

I'm not really sure, but I had problems receiving the events from my panel and I think the solution was to change the line to

misc("externalWindowHandle") = ParentHWnd.ToString()

Give it a try... Maybe bekas should change the c# win form example if it is working for you too.

Roland from Germany


17-10-2006 21:55:16

Yeah, it should be "externalWindowHandle", good catch. I updated SVN.


17-10-2006 23:17:45

Yes! That solved the problem. Thanks for the tip and thanks again all for your quick responses.

///. Tom H


27-10-2006 21:36:04

Hey, i'm a new user to Mogre and I seem to be having problems with the CreateWindow function in VB for the Mogre.Forms example. The last parameter of the function seems to accept a Const_NamePairList type but you can only create a NamePairList class. I tryed a CType, DirectCast and TryCast with Option Strict On to get the param to accept it but the compiler rejects it. How does this work?


27-10-2006 23:40:14

It's an implicit type conversion in C#, doesn't VB.NET support it ?
You can use the 'ReadOnlyInstance' property of NamePairList to get the Const type.


28-10-2006 10:38:26

VB.NET does support implicit conversions with


but this doesn't work with the NamePairList (error is something like cannot convert NamePairList to Const_NamePairList) but the ReadOnlyInstance is working fine with


28-10-2006 11:55:00

You're right, it supports it and you don't even have to use ctype:
Dim m1 As Mogre.ResourcePtr = Nothing
Dim m2 As Mogre.MaterialPtr

m2 = m1

But for some reason, implicit conversion to Const_* classes doesn't work for VB.NET. You can do
Dim c1 As Mogre.LightList = Nothing
Dim c2 As Mogre.Const_LightList

c2 = Mogre.LightList.op_Implicit(c1)

but VB doesn't pick it up automatically.
Weird :?