I've had some success using the CLR and the Forms even though in the P3D SDK there is no mention of C ++ but only for C#.
I could connect with the SimConnect server:
i could also set a message queue:private: System::Void MainForm_Load(System::Object^ sender, System::EventArgs^ e) {
try
{
Sim_Connect = gcnew SimConnect(safe_cast<String^>("tf104gconfig"), IntPtr::Zero, 0, nullptr, 0);
}
catch (Exception ^ex)
{
String^ message = "Could not connect with sim\napplication will close.";
String^ caption = "TF-104 G CONFIGURATOR";
MessageBoxButtons buttons = MessageBoxButtons::OK;
MessageBox::Show(this, message, caption, buttons);
Sim_Connect = nullptr;
Application::Exit();
}
}
Queue seems to work well entrapping all WM messages but nothing coming from the SimConnect server, so i'm stuck here.protected: virtual void DefWndProc(Message% m) override {
printf("\nMessage:%d", m.Msg);
if (m.Msg == WM_USER_SIMCONNECT){ //0x0402
if (Sim_Connect != nullptr)
Sim_Connect->ReceiveMessage();
}
else
System::Windows::Forms::Form::DefWndProc(m);
}
P3D v4 SDK seems to be of little help since the translation from C# to C++ is not straightforward.
My goal is to make an external application (an aircraft configurator) able to talk with the sim via SimConnect.
Actually the only way i could have is an inelegant file cross talk.
Thanks in advance to anyone who can give me a cue or better an example code
Mario Motta