Embed XNA in WinForms
Asked Answered
G

2

17

Is it possible to embed an XNA game in a C# WinForm or a C++ Window. If yes then How.

I want to use normal UI controls & have a windowed interface of the game for more interactive & dynamic simulations.

Gaby answered 2/7, 2011 at 16:13 Comment(1)
the Googled results were complicated and the those results didn't led to what Andrew mentioned belowGaby
G
21

The official samples:

Gather answered 2/7, 2011 at 17:25 Comment(3)
yes.. i would go for this as well as it is official from Microsoft as wellGaby
SIDE NOTE: Neither addresses the issue of Mouse input interaction with the scene.Quadrangular
I've answered your question here. Basically you must set Mouse.WindowHandle correctly (or use WinForms events).Gather
L
5

I've had success doing this using the method described here:

XNA 3.0 and Winforms, the easy way

The blog post was written for XNA 3.0, but I had no problems using the same method with XNA 4.0.

It's very simple compared to the official Microsoft sample, but as this method is not officially supported, you should use it at your own risk. It worked perfectly in my case, and it required only minimal changes to the Game class.

Linger answered 3/7, 2011 at 4:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.