• 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.

Creating FSX Modules??

i ve used also " Panels" but bracket error remains!!!!

I was not saying changing the name fixes the compilation error, but just that if you don't use the name "Panels" then Simconnect won't find it and fill it is, so if you ever did get to compile and run your program it would crash there with a zero pointer!

i use gauges.h WITHOUT mod....

What, the one from FS2004 or the one in the Panels SDK from the Deluxe edition SDKs? Let me check. I've always used my own without all the stuff I don't use (I have never made gauges).

....

Okay. I have looked in that, and I cannot see any sign of a procedure called "execute_code_calculator". The only one similar in the PANELS structure is:

BOOL (FSAPI *execute_calculator_code) (PCSTRINGZ code, FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);

Are you sure you are not simply trying to use an incorrectly named entry?

Regards

Pete
 
Originally Posted by Pete Dowson:
I was not saying changing the name fixes the compilation error, but just that if you don't use the name "Panels" then Simconnect won't find it and fill it is, so if you ever did get to compile and run your program it would crash there with a zero pointer!

Yes, that is true......karijno, you have to name it as "Panels", because after SimConnect load your module, will look for a pointer called "Panels", if it doesnt finds it, it will not fill that pointer, as result, it will remain as a NULL pointer, causing a possible crash if you try call it.

At this point, i may suggest you, karijno, to do a cross-check after your module is loaded by SimConnect, to do a: "if (Panels == NULL)", then display some kind of warnning or something like that so you can see (during your tests), when the pointer had been filled or not, before calling any function from it...And also check that you are calling the correct name entry, as Pete, said, if you call an incorrect function entry, it will not recognize it....:)

Best Regards,

Manuel Ambulo
 
Last edited:
I thought I followed instructions (for a change :)) but had absolutely no luck with getting SimConnect to populate the Panels pointer - until I discovered the problem.

YOU MUST HAVE A DEFINITION FILE (.DEF) ATTACHED TO YOUR PROJECT OR *Panels DOESN'T POPULATE.

The catch is that a module definition file is technically not needed (per VS2005 docs) as the "inherent" export happens simply because of the __declspec(dllexport) keyword is present. That works fine for functions apparently, but not for variables.

The solution is to add a definition file to the project and not rely on the automatic export of symbols.


A basic FSX module dll in C++ looks like this:

Code:
// EXTERN_C normally defined in winnt.h
//
//#ifdef __cplusplus
//   #define EXTERN_C    extern "C"
//#else
//    #define EXTERN_C    extern
//#endif

// FSX module template

#include "gauges.h"

EXTERN_C __declspec(dllexport) PANELS *Panels;

EXTERN_C __declspec(dllexport) int DLLStart() 
{
   // called by SimConnect when dll is loaded
   return 0;  // return 0 for S_OK or load is cancelled
}

EXTERN_C __declspec(dllexport) int DLLStop()
{
  // called by SimConnect when dll is unloaded
  return 0;
}

// dll entry point - not called by SimConnect - this is called direct when the library is loaded by the O/S
EXTERN_C BOOL WINAPI  DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
	switch (fdwReason) {
		case DLL_PROCESS_ATTACH:
                        //good place to hook the main window handle if needed using FindWindow("FS98MAIN", NULL);
			break;

		case DLL_PROCESS_DETACH:
			break;
			
	}

	return TRUE;
}

The module definition (.def) file for the above is here:

Code:
LIBRARY	"your_module_name_goes_here"
EXPORTS
DLLStart
DLLStop
Panels

The *Panels pointer is populated by the time DLLStart() is called so the functions it references (including execute_calculator_code) can be used during or after DLLStart() executes.

Another thing to note is the function names are case sensitive, and DLLStart() works, where DllStart() does not...

Cheers,

Etienne
 
Last edited:
YOU MUST HAVE A DEFINITION FILE (.DEF) ATTACHED TO YOUR PROJECT OR *Panels DOESN'T POPULATE.

Well, odd that then. I've never made any .DEF file, just using:

EXTERN_C __declspec(dllexport) PANELS *Panels;

in my code, and it always populates correctly. I am using VS2005. Maybe there's something else in the project properties doing it?

Regards

Pete
 
Well, odd that then.

What can I say Pete! It seems that oddities are the rule in the FS world :)

I'm thinking perhaps a default behavior difference between the C and C++ compilers/linkers and how the manifest ends up in the dll. Clearly something different in the linking process. It may also has to do with how Simconnect looks up the entry points.

One thing for sure in my case - removing the def file, even while compiling and running just fine, leaves *Panel to a null pointer, and has no errors.

The Simconnect doc does indicate a DEF file is needed, which I admittedly ignored completely. I'm running VS2005 SP1 if that makes a difference as well.

Regards,

Etienne
 
Back
Top