• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Display messages via SimConnect?

In managed code I don't think that it's possible to do anything with the pointer. I stumble on this solution when I was looking for a solution for 3d dialog rendering over FS2004 in full screen. It isn't dificult to do that kind of rendering but you need to sync it with the frame otherwise it will flicker. To sync it you need the device pointer.

José
 
Wow!!, that would be really nice to see, a special renderer for FS, (would look images more realistic...)...but yes...same as amazing, same should be **hard** (i think), getting or intercept the device pointer...and then sync as you said....

Best Regards,

Manuel Ambulo
 
Did you ever look at the .spb files in the dialogs subfolder of FSX? I wonder whether this can be used for dialogs. They look like old school resource files for dialogs to me and i'm sure them ACEs have a compiler for that stuff that they don't want to hand out as part of the SDK.

Showing modal dialogs on top of FSX works well with managed simconnect when FSX is in window mode, it would work well too in fullscreen mode if FSX wouldn't automatically minimize then when it's window looses focus (SimConnect.SetSystemState("DialogMode",1,0.0F,"")).
 
Did you ever look at the .spb files in the dialogs subfolder of FSX? I wonder whether this can be used for dialogs. They look like old school resource files for dialogs to me and i'm sure them ACEs have a compiler for that stuff that they don't want to hand out as part of the SDK.

Compiler is already in the SDK; see Core Utilities/SimProp. For a decompiler, look at spb2xml on avsim.
I think those files are used for localisation, and you cannot bring up a full-featured dialog window just by writing a SPB file and telling FS to read and show it.
If you want FS look-alike windows, you may use ui.dll/fsui.dll. They export some C++ decorated functions (well, 2400 of them). Still less valuable than documented headers, but you can probably build a GUI without the ordinary pain of guessing ordinals,arguments etc. ;)
 
Never looked at SimProp so far, but thanks for the hint. I would actually be satisfied if switching to "DialogMode" via SimConnect would allow to pop up own dialogs in full screen mode without FS window minimizing.
I don't think this is DirectX default behaviour like someone mentioned if i remember right from my DirectX experiments and FS does it too with several dialogs (map, aircraft selection etc.). There is also a setting in DirectX that allows to pop up normal windows on top of a directx full screen window, not sure you can change that at runtime (it costs a lot of frames and has some sideeffects).

I think though they should add some simple dialog functions to SimConnect for a number of reasons. First the client is not necessarely on the same machine as FS and second there should be a supported method that doesn't break when a new version comes out. Something like showing the mission descriptions or a ingame dialog like the ATC window with title, text and a number of selections, result sent back to client. I found some dirty stuff to do that but an official way would be appreciated.
 
Hello, I used this function PrintMessage.

If I do it :
Code:
.
.
.
struct AdvMessage {
char* message;
int style;
int delay;
int cleanup;
};
.
.
.
msg->message="Hello Pilot!";
msg->style=4;msg->delay=100;msg->cleanup=0;
PrintMessage(msg);.
This code works well


but I've some difficult to affect string of characters for msg->message in this code :
Code:
TCHAR pszDest[256];
hr=StringCchPrintf(pszDest,256,TEXT("Kohlsmann=%f - Altitude=%f - Latitude=%f - Longitude=%f\0"),pS->kohlsmann,pS->altitude,pS->latitude,pS->longitude);
msg->message=(char *)pszDest;
msg->style=4;msg->delay=100;msg->cleanup=0;
PrintMessage(msg);
This code make an error of FSX :
error_fsx_1.jpg


I tried strcpy(), same error.......

I tried other code :
Code:
char* pszDest;
sprintf(pszDest,"TEST! %f",pS->kohlsmann);
msg->message=pszDest;
msg->style=4;msg->delay=100;msg->cleanup=0;
PrintMessage(msg);
It works but It displays bad characters.......

What is the solution ?

Regards,

Chris.
 
You should not use TCHAR, wchar_t or other multibyte char encodings. I don't know if FSX can handle them everywhere.
The last code snippet has a problem, you didn't allocated memory for pszDest.
Try :
Code:
char pszDest[32];
snprintf(pszDest, 32, "TEST! %f",pS->kohlsmann);
msg->message=pszDest;
msg->style=4;msg->delay=100;msg->cleanup=0;
PrintMessage(msg);
 
Okay thanks lc0277,

I tried this code.
First, snprintf doesn't know for VC++ 2005 express.
But _snprintf yes, there is.

I tested, it doesn't work :(

Same error.......
Very Surprised.

Anyelse, "TANT PIS" (french words) :D

I'll use only quotes for sometimes.

Regards,

Chris.
 
Hello all,

Well, I think to find solution about my problem, it's suitable to do it for example my code :

Code:
void PrintMessage(char *msg)
{
.
.
.
if (FsxProc != NULL) FsxProc(msg, 4, 100, 0);

I removed the struct *msg. It could make some bug...
Then I changed it to variable char* msg.

Also, I didn't tried but it could work this :
Code:
void PrintMessage(char *msg, int style, int delay, int cleanup)
{
.
.
.
if (FsxProc != NULL) FsxProc(msg, style, delay, cleanup);

Regards,

Chris. :)
 
Very nice stuff, thanks all.

Jose, one comment: have you looked into the unsafe keyword in C#? Pointers do work as they do in C/C++ inside an unsafe block, but using the pointer outside the managed environment may be a different issue altogether.

I also ran across an interesting post on CodeProject and associated reference on hosting the CLR from regular c++ (I'm thinkin, FS module :) )

http://www.codeproject.com/csharp/unmanagedtomanaged.asp

Haven't played with it yet - my last attempt with the regular C++ using the /clr switch caused a GPF in FSX with a memory allocation problem (probably the GC at work). This seems to be a completely different approach.
 
I made an experiment with a native C(--) wrapper dll around a managed VB8 dll in FSX based on the code project description and a similar MSDN paper.

When the C dll gets the Start/Stop calls i just call matching functions in the managed dll. Basically it works to wrap managed stuff but i had some weird behaviour and decided for the sake of performance and stability not to use managed code inside the FSX process. So i have a C dll for all that inside stuff that offers some functionality to my managed exe's avialable via SimConnect custom data areas and events.
 
I made an experiment with a native C(--) wrapper dll around a managed VB8 dll in FSX based on the code project description and a similar MSDN paper.

When the C dll gets the Start/Stop calls i just call matching functions in the managed dll. Basically it works to wrap managed stuff but i had some weird behaviour and decided for the sake of performance and stability not to use managed code inside the FSX process. So i have a C dll for all that inside stuff that offers some functionality to my managed exe's avialable via SimConnect custom data areas and events.

The "weird" behavior is probably the best way to characterize it, definitely very unpredictable. I find the unstable part very odd, as the managed run itself seems quite stable. It's the return to unmanaged code that seems to be a problem with either a lockup or GPF in FS. What I find more interesting is that a regular wrapper (outside of FSX) with similar code seems to work just fine. Oh well.

Etienne
 
My suspicion for the weird behaviour is, that the addon dll is started in it's own thread and this thread has no windows message queue associated. So calls that show windows or do something gui related won't work, unless you create and associate a message queue with the current thread. I didn't try that though since as i said above it's currently not the way to go for me.
Could be something else too though, such as that the CLR might not run properly if it doesn't have control of the process main thread.
I know that the simconnect open in my managed dll worked due to the simconnect console output but writing a logfile log or opening a message box didn't.
 
Back
Top