By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

XNA game window as a form control ?

P: n/a
Hi,
Ive got a 3d model editor wich im developing
with XNA c# development environment,

using the game window to display the wireframe mesh in 3d.
however I need to use some other windows too,
such as a Form type window wich displays lists of numerical details
about objects in the 3d view and allows objects to be selected from a list
as an alternative to selecting them on the 3d view
as they maybe underneath another object.

If I run the game from within a Form
it complains -"cant have more than one message loop"

so Ive made the form and XNA game window seperate threads,
wich works ok they both display and work ok
but I need to share the keyboard focus between the two
as I need to click on some controls on the form
but still have keyboard input accepted by the game window.

I can probably get round this by routing key input from either
thread, but I will need to process the mouse hover over a control in the
form
and look for 3d objects under the cursor in the game window
etc wich makes it more tricky.

What would be nice is if I could make the game window part of the form,
like a child control, is this possible ?
the XNA Game class seems to make a window wich has virtually
no control over how its created or any builtin functions to access the
window.

I gues the Window handle is acessable, I used to do some low level window
stuff
but its been a long time since, anyone know if this is possible or how to do
it?

Colin =^.^=
Nov 26 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a

Ive tried by simply calling the windows api SetParent to set the parent of
the
xna game window to be the form window, it displays and draws ok but it locks
up.

the cursor wont even move out of the form window I have to use task manager
to close it
as I cant even move the mouse to the IDE.

What else do I need to do to get it to run ?
I just need the xna window to stay visible on top of the form window.
Im so rusty with doing it the low level way...

Colin =^.^=
"colin" <co*********@ntworld.NOSPAM.comwrote in message
news:mh******************@newsfe7-gui.ntli.net...
Hi,
Ive got a 3d model editor wich im developing
with XNA c# development environment,

using the game window to display the wireframe mesh in 3d.
however I need to use some other windows too,
such as a Form type window wich displays lists of numerical details
about objects in the 3d view and allows objects to be selected from a list
as an alternative to selecting them on the 3d view
as they maybe underneath another object.

If I run the game from within a Form
it complains -"cant have more than one message loop"

so Ive made the form and XNA game window seperate threads,
wich works ok they both display and work ok
but I need to share the keyboard focus between the two
as I need to click on some controls on the form
but still have keyboard input accepted by the game window.

I can probably get round this by routing key input from either
thread, but I will need to process the mouse hover over a control in the
form
and look for 3d objects under the cursor in the game window
etc wich makes it more tricky.

What would be nice is if I could make the game window part of the form,
like a child control, is this possible ?
the XNA Game class seems to make a window wich has virtually
no control over how its created or any builtin functions to access the
window.

I gues the Window handle is acessable, I used to do some low level window
stuff
but its been a long time since, anyone know if this is possible or how to
do it?


Nov 28 '07 #2

P: n/a
actually it runs ok exept when the form is shown so that the child game
window
is obscured by the task bar at the bottom, then it locks up,
anyone got any idea whats going on ?

I dont know why but my forms often are positioned so they are obscured
by the task bar at the bottom wich is 2 rows high wich is slightly anoying.

Colin =^.^=
"colin" <co*********@ntworld.NOSPAM.comwrote in message
news:UK******************@newsfe3-gui.ntli.net...
>
Ive tried by simply calling the windows api SetParent to set the parent of
the
xna game window to be the form window, it displays and draws ok but it
locks up.

the cursor wont even move out of the form window I have to use task
manager to close it
as I cant even move the mouse to the IDE.

What else do I need to do to get it to run ?
I just need the xna window to stay visible on top of the form window.
Im so rusty with doing it the low level way...

Colin =^.^=
"colin" <co*********@ntworld.NOSPAM.comwrote in message
news:mh******************@newsfe7-gui.ntli.net...
>Hi,
Ive got a 3d model editor wich im developing
with XNA c# development environment,

using the game window to display the wireframe mesh in 3d.
however I need to use some other windows too,
such as a Form type window wich displays lists of numerical details
about objects in the 3d view and allows objects to be selected from a
list
as an alternative to selecting them on the 3d view
as they maybe underneath another object.

If I run the game from within a Form
it complains -"cant have more than one message loop"

so Ive made the form and XNA game window seperate threads,
wich works ok they both display and work ok
but I need to share the keyboard focus between the two
as I need to click on some controls on the form
but still have keyboard input accepted by the game window.

I can probably get round this by routing key input from either
thread, but I will need to process the mouse hover over a control in the
form
and look for 3d objects under the cursor in the game window
etc wich makes it more tricky.

What would be nice is if I could make the game window part of the form,
like a child control, is this possible ?
the XNA Game class seems to make a window wich has virtually
no control over how its created or any builtin functions to access the
window.

I gues the Window handle is acessable, I used to do some low level window
stuff
but its been a long time since, anyone know if this is possible or how to
do it?



Nov 28 '07 #3

P: n/a
well after looking several times over the last fee days
I finally came across this
http://www.fairyengine.com/articles/xnainform.htm
looks like its what I need,

kinda complicated as the basic xna loop is
re implemented in the form loop.
but manages to put 2 3d windows on a form :D
looks realy cool, and a pretty 3d tiger too

many thanks to the author of that article.

Colin =^.^=
"colin" <co*********@ntworld.NOSPAM.comwrote in message
news:mh******************@newsfe7-gui.ntli.net...
Hi,
Ive got a 3d model editor wich im developing
with XNA c# development environment,

using the game window to display the wireframe mesh in 3d.
however I need to use some other windows too,
such as a Form type window wich displays lists of numerical details
about objects in the 3d view and allows objects to be selected from a list
as an alternative to selecting them on the 3d view
as they maybe underneath another object.
........
Nov 28 '07 #4

P: n/a
You need to read this thread:

http://forums.xna.com/thread/10288.aspx

I posted the head on that. The performance is just crap, though. I'd
suggest using WPF instead.
Nov 29 '07 #5

P: n/a
"not_a_commie" <no********@gmail.comwrote in message
news:2b**********************************@s8g2000p rg.googlegroups.com...
You need to read this thread:

http://forums.xna.com/thread/10288.aspx

I posted the head on that. The performance is just crap, though. I'd
suggest using WPF instead.
Cool thanks, the last post on that thread looks promising,
the XnaView class I posted does it by copying it to a texture,
then copying it to the control, xna2.0 looks like you can set
the xna destination window directly.

I just looked up WPF wich is in .net3 and gives you "richer 2d/3d etc..."
Ive already written a lot of code that works on XNA,
xbox compatability isnt an issue, its just a wire model editor.
the real headache is trying to come up with a user interface that
works well, the existing editor interface doesnt work well for me at all
although I know a lot of people have got realy used to it.

hmm wich way to go, xna2.0 or .net3 ...
I wonder wich would need the least amount of code to re write.
seems I already have xna2.0 and most people probably only have .net2 atm
im not clear if that solution for xna2.0 could handle multiple windows,
it might be usefull to have more than one view, although
for orthoganal only one true 3d view is needed,
but its easier if the same drawing system is used for each.

I might well subscribe to that forum looks right up my alley atm.
many thanks,
Colin =^.^=
Nov 29 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.