- Messages
- 112
- Country
Morning chaps. Long time no visit. Hope you're all surviving lockdown[n].
Please can you give me a nudge in the right direction?
I've previously coded a prototype "application" (=scrappy bit of test code) in VBA that successfully connected to SimConnect and exchanged various bits of flight dynamics data and control events.
I'm now trying to do something similar but thought VBA was perhaps not the greatest idea so thought that maybe C# would be a better choice not least because I've got basic skills in this.
Having read a bunch of examples in the ancient (FSX) SimConnect examples and a few slightly later ones in LM's documentation I took a deep breath and started upsetting Visual Studio.
Given the nature of the application (I want to interface some physical gauges - compass & ADI initially and a control column - not USB joystick) I thought that a Console app would be a good start, but immediately ran into a problem that was beyond my depth of understanding: The sample code I was (ahem) "inspired by", passes a form handle to SimConnect and elsewhere uses Windows forms messaging capabilities to manage update events.
and later:
Is there a way to achieve the same with a CONSOLE app (i.e. no forms)? How do I catch the messages from SImConnect?
I found references to managed code console apps on Beatle's deceased blog page (well the page is there but the sample code isn't), and in a thread on a Delphi port here (which felt like a rabbit hole that was unlikely to help) and have drawn a blank with my web searches.
I suspect I could get it working by giving up and using a form, but I'd rather not if I don't have to.
Thanks in advance,
Z
Please can you give me a nudge in the right direction?
I've previously coded a prototype "application" (=scrappy bit of test code) in VBA that successfully connected to SimConnect and exchanged various bits of flight dynamics data and control events.
I'm now trying to do something similar but thought VBA was perhaps not the greatest idea so thought that maybe C# would be a better choice not least because I've got basic skills in this.
Having read a bunch of examples in the ancient (FSX) SimConnect examples and a few slightly later ones in LM's documentation I took a deep breath and started upsetting Visual Studio.
Given the nature of the application (I want to interface some physical gauges - compass & ADI initially and a control column - not USB joystick) I thought that a Console app would be a good start, but immediately ran into a problem that was beyond my depth of understanding: The sample code I was (ahem) "inspired by", passes a form handle to SimConnect and elsewhere uses Windows forms messaging capabilities to manage update events.
C#:
if (simconnect == null)
{
try
{
simconnect = new SimConnect("Managed Data Request", this.Handle, WM_USER_SIMCONNECT, null, 0);
//the "this.Handle" is never going to work here. No form=no handle?
initDataRequest();
}
catch (COMException ex)
{
mLog.LogInformation("Unable to connect to SimConnect:\n\n" + ex.Message);
}
...
and later:
C#:
protected override void DefWndProc(ref Message m)
//No "Message" without a form
...
Is there a way to achieve the same with a CONSOLE app (i.e. no forms)? How do I catch the messages from SImConnect?
I found references to managed code console apps on Beatle's deceased blog page (well the page is there but the sample code isn't), and in a thread on a Delphi port here (which felt like a rabbit hole that was unlikely to help) and have drawn a blank with my web searches.
I suspect I could get it working by giving up and using a form, but I'd rather not if I don't have to.
Thanks in advance,
Z