Swinging For The Fences
Leave it to me, of all people, to start hard.
I was trying to decide what to do first, a SimConnect project or a XNA project. Then I was struck with most absurd bit of inspiration and decided to combine the two. My first project on this blog is a Primary Flight Display for FSX, written in XNA and connecting with SimConnect. Right away, this presents a problem.
XNA is a cross-platform framework, meant to compile for both Windows XP and XBox360. This means that certain functionality, such as WinForms, is not natively present in the framework. SimConnect, on the other hand, is assuming that you are using standard .NET to create your programs and libraries. So they pass data to you via system messages. Here is the sample override for the defwndproc:
This works great if you are using System.Windows.Forms, however the XNA Framework class 'Game' doesn't have a DefWndProc to override. Right now, the only option that presents itself would be to create a dummy windows form by including a reference to WinForms, and then calling the event handlers from there. This shouldn't be as tricky as it seems. I'll just put the call to run the game in the constructor for the Form class, and roll from there.
I'll see how that goes and update back here.
I was trying to decide what to do first, a SimConnect project or a XNA project. Then I was struck with most absurd bit of inspiration and decided to combine the two. My first project on this blog is a Primary Flight Display for FSX, written in XNA and connecting with SimConnect. Right away, this presents a problem.
XNA is a cross-platform framework, meant to compile for both Windows XP and XBox360. This means that certain functionality, such as WinForms, is not natively present in the framework. SimConnect, on the other hand, is assuming that you are using standard .NET to create your programs and libraries. So they pass data to you via system messages. Here is the sample override for the defwndproc:
protected override void DefWndProc(ref Message m)
{
if (m.Msg == WM_USER_SIMCONNECT)
{
if (simconnect != null)
{
simconnect.ReceiveMessage();
}
}
else
{
base.DefWndProc(ref m);
}
}
This works great if you are using System.Windows.Forms, however the XNA Framework class 'Game' doesn't have a DefWndProc to override. Right now, the only option that presents itself would be to create a dummy windows form by including a reference to WinForms, and then calling the event handlers from there. This shouldn't be as tricky as it seems. I'll just put the call to run the game in the constructor for the Form class, and roll from there.
I'll see how that goes and update back here.
Labels: .NET, SimConnect, XNA
0 Comments:
Post a Comment
<< Home