Jump to content
Sign in to follow this  
Guest qsysk

Module, gauge and network question

Recommended Posts

Guest wysspeter

Hi,I have some questions about module and gauge programming.I've managed to program a simple gauge in C and a simple module showing a menu. But is it somehow possible to combine these two things? I'd like to have a module (dll) showing and interacting with a gauge or a module that can display things inside the FS. I don't need the gauge inside a panel. Do I need to link these 2 files or is it possible to include the gauge in the dll module?And another question: As far as I undestand I can use almost everything from windows. So what would you recommend to use networking in a module? I need to open a TCP connection to send some data.

Share this post


Link to post
Share on other sites
Guest qsysk

There are a lot of ways to perform what you want.1.In the fs9gauges.h there is macro (GAUGE_TABLE_BEGIN) that defines the DllMain proc, which is the dlls entry point. (Gauges(.gau) and modules(.dll) are actually are the same. The extension is different.As you may have noticed ..in order to add a menu you have to overload WndProc of the FS window(using the SetWindowLong API).So, what you can do is to built your own GAUGE_TABLE_BEGIN macro(without including the DllMain as FSSDK does) and built your own DllMain,WndProc and menu addition code. Here is a example of haw the macro should be#define GAUGE_TABLE_BEGIN_NO_MAIN() extern GAUGEHDR gauge_header; void FSAPI module_init(void){} void FSAPI module_deinit(void){} /* This is the module's import table. */ GAUGESIMPORT ImportTable = { { 0x0000000F, (PPANELS)NULL }, { 0x00000000, NULL } }; /* This is the module's export table. */ GAUGESLINKAGE Linkage = { 0x00000013, module_init, module_deinit, 0, 0, FS9LINK_VERSION, {In this solution there is only one gau file that means that you can use variables in order to IO data.Note that a very simple gauge should be defined. in any other case the FS won't load the gauge file. Also this will work per aircraft, gauge is defined for loading in the panel.cfg2. In the other hand, you may have 2 files. a .gau and a .dllThe .dll should export some functions or data(use of the __declspec(dllexport)) function modifier. The .gau should call LoadLibrary("YourDllPath") to load the .dll athen GetProcAddress(DLL_HMODULE,"FunctionNameOrData") in order to locate the exported proc/data.example:In the Module file: /* in a .h file */extern "C" __declspec(dllexport) int MyExportedProc();extern "C" __declspec(dllexport) int MyExportedData;/* in a .c/cpp file */ int MyExportedData = 0;int MyExportedProc();{ /* Do something */};In the Gauge Fileint (MyImportedProc*)(void);int* MyImportedData;void LoadExportedProc(){ HMODULE hDll = LoadLibrary("ModulesMyDll.dll"); MyImportedProc= (int(*)())GetProcAddress(hDll,"MyExportedProc"); MyImportedData=(int*)GetProcAddress(hDll,"MyExportedData");};I hope it helps

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...