Jump to content
Sign in to follow this  
mgh

Creating Gauges using Borland C++Builder

Recommended Posts

Has anyone experience of creating gauges using Borland C++Builder. I have Version 4 Professional?Alternatively, can anyone direct me me to a website with any information/advice about this?I've written in C and C++ for a few years but find the MS SDK and the program structure confusing to put it mildly. For example the main entry pointBOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)seems to be hidden away in the definition of GAUGE_TABLE_BEGIN() in gauges.h.

Share this post


Link to post
Share on other sites

I've made some progress. I've compiled the SDK fuel gauge but it's now incompatible with FS9 so I still need advice :(Borland C++Builder permits building a .dll file but requires that it has the main DLL entry point in it, else it can't be saved. I therefore edited gauges.h to remove the following lines from the GAUGE_TABLE_BEGIN macro and put them in the main DLL code:extern GAUGEHDR gauge_header;void FSAPI module_init(void){}void FSAPI module_deinit(void){}BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved){ return TRUE;}I followed them immediately with the GAUGE_TABLE_BEGIN macro.I decided to work with only the fuel gauge to keep things simple(!)so edited the SDK.c, SDK.h, and SDK.rc files to remove all references to other gauges.My main DLL code became://-------------------------------------------------------------------// Microsoft Flight Simulator 2004 - Gauge Compiler for C++Builder4//-------------------------------------------------------------------// Includes#include #include #pragma hdrstop//-------------------------------------------------------------------// SDK.c "includes" gauges.h, SDK.h, and SDK.Fuel.c //-------------------------------------------------------------------#include "SDK.c"//-------------------------------------------------------------------// Resource FileUSERC("SDK.rc");//-------------------------------------------------------------------// Definitions removed from gauges.h//-------------------------------------------------------------------extern GAUGEHDR gauge_header;void FSAPI module_init(void){}void FSAPI module_deinit(void){}//-------------------------------------------------------------------// Main entry point removed from gauges.h//-------------------------------------------------------------------BOOL WINAPI DllEntryPoint(HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved){return TRUE;}//-------------------------------------------------------------------// Gauge table //-------------------------------------------------------------------GAUGE_TABLE_BEGIN()GAUGE_TABLE_ENTRY(&gaugehdr_fuel)GAUGE_TABLE_END()//-------------------------------------------------------------------This compiles to to a .dll file. This is 141kb which is a similar size to existing fuel gauge (.gau) files. I'd set the version information in SDK.rc and this appears in the compiled .dllI renamed it as a .gau file, put it in the FS gauges folder, added a reference to it an a panel.cfg file put got a message that it was incompatible when loading the aircraft.What am I doing wrong? All help gratefully received!

Share this post


Link to post
Share on other sites

I tried this and it works OK (I'm using Microsoft C):/*/////////////////////////////////////////////////////////////////////////////// Gauge table entries/////////////////////////////////////////////////////////////////////////////GAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&gaugehdr_attitude) GAUGE_TABLE_ENTRY(&gaugehdr_control_surfaces) GAUGE_TABLE_ENTRY(&gaugehdr_fuel) GAUGE_TABLE_ENTRY(&gaugehdr_fuel_selector) GAUGE_TABLE_ENTRY(&gaugehdr_temperature) GAUGE_TABLE_ENTRY(&gaugehdr_wiskey) GAUGE_TABLE_ENTRY(&gaugehdr_flightmap)GAUGE_TABLE_END()*/void FSAPI module_init(void){} void FSAPI module_deinit(void){} BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved) { return TRUE;}GAUGESIMPORT ImportTable = { { 0x0000000F, (PPANELS)NULL }, { 0x00000000, NULL } };GAUGESLINKAGE Linkage ={ 0x00000013, module_init, module_deinit, 0, 0, FS9LINK_VERSION, { (&gaugehdr_attitude), (&gaugehdr_control_surfaces), (&gaugehdr_fuel), (&gaugehdr_fuel_selector), (&gaugehdr_temperature), (&gaugehdr_wiskey), (&gaugehdr_flightmap), 0 }};All I've done here is comment out the GAUGE_TABLE macro, and substitute the code the macro contains.Doug

Share this post


Link to post
Share on other sites

No luck. I get, as before, an apparently valid .dll file that FS doesn't like :(There are no error messages, all the version information is there, the size seems OK but......I need help!

Share this post


Link to post
Share on other sites

Are you using the stock GAUGES.H file, or the one modified by Arne Bartels and Dai Griffiths? I believe some of the mods Arne and Dai have done are to ensure compatibility with GCC and BCC. If you are using the stock file, you might try the attached.Doug

Share this post


Link to post
Share on other sites

Thanks. I've been using the stock gauges.h file. I'll try the one you suggest.

Share this post


Link to post
Share on other sites

I tried it but no success. FS9 still won't recognise my gauge.I checked the first word in my gauge file and against an MS gauge - they are identical at 4D 5A. This is the same as a normal dll so the signature seems OK.I'm running out of ideas. Anyone know what FS checks for in a gauge?

Share this post


Link to post
Share on other sites

Success :)I finally got my gauge to work by changing the Borland C++Builder Project Options from the default ones - mainly by omitting debug information. For the record, the changes were:Advanced Compiler:- No Autodependency output- No Generate Underscores- Standard Call (not C)Compiler:- No Debug Information- No Line Number Information- No Disable Inline Expansions- No Stack FramesLinker- No Generate Debug Information- No Use Debug Libraries- No Generate Import Library I'm not certain that all of them are necessary but that combination gives a valid dll/gau file.

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