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

VS2010 + C++ gauge

Messages
73
Hello everybody !

I would like to know what type of project I have to create to build a C++ gauge using VS2010.

I already tried to create a Win32 DLL Project but the gauges.h "DEFINES" are useless.

Of course, the "gauges.h" is include to my .cpp

Thank you in advance

PS : "Sorry for my english"
 
Hello n4gix !

Thank you for your answer !

I follow your tutorial but I have 2 issues :

Erreur 1 error LNK2001: symbole externe non résolu "struct ELEMENT_HEADER * sdmanager_list" (?sdmanager_list@@3PAUELEMENT_HEADER@@A) C:\Documents and Settings\SkyDreamUser\Bureau\SDManagerGauge\SDManagerGauge\SDManagerGauge.obj SDManagerGauge

Erreur 2 error LNK2001: symbole externe non résolu "struct MOUSERECT * sdmanager_list_mouse_rect" (?sdmanager_list_mouse_rect@@3PAUMOUSERECT@@A) C:\Documents and Settings\SkyDreamUser\Bureau\SDManagerGauge\SDManagerGauge\SDManagerGauge.obj SDManagerGauge

Just look at my project :

SDManagerGauge.cpp :

Code:
#include "gauges.h"
#include "SDManagerGauge.h"
#include <MMSystem.h>
#include <math.h>

#define GAUGE_NAME            "SDManagerGauge\0"
#define GAUGEHDR_VAR_NAME    gaugehdr_SDManagerGauge
#define GAUGE_W                100
#include "SDManagerGaugeG.cpp"

GAUGE_TABLE_BEGIN()
    GAUGE_TABLE_ENTRY(&gaugehdr_SDManagerGauge)
GAUGE_TABLE_END()

SDManagerGauge.h :

Code:
#define         VERSION_MAJOR           1
#define         VERSION_MINOR           0
#define         VERSION_BUILD           0

#define     lita(arg) #arg
#define     xlita(arg) lita(arg)
#define     cat3(w,x,z) w##.##x##.##z##\000
#define     xcat3(w,x,z) cat3(w,x,z)
#define     VERSION_STRING xlita(xcat3 (VERSION_MAJOR,VERSION_MINOR,VERSION_BUILD))

#ifndef           VS_VERSION_INFO
#define           VS_VERSION_INFO         0x0001
#endif

// On incrémente de 10 en 10 c'est plus logique
#define Rec0 0x1000
//#define Rec1 0x1010
//#define Rec2 0x1020
//#define Rec3 0x1030

SDManagerGaugeG.cpp :

Code:
char sdmanager_gauge_name[]    = GAUGE_NAME;
extern PELEMENT_HEADER        sdmanager_list;
extern MOUSERECT            sdmanager_list_mouse_rect[];

GAUGE_HEADER_FS700(GAUGE_W, sdmanager_gauge_name, &sdmanager_list, sdmanager_list_mouse_rect, 0, 0, 0, 0);

SDManagerGauge.rc :

Code:
#include "SDManagerGauge.h"

VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION_MAJOR,VERSION_MINOR,0,VERSION_BUILD
PRODUCTVERSION VERSION_MAJOR,VERSION_MINOR,0,VERSION_BUILD
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x10004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
    END
END

REC0        BITMAP DISCARDABLE        "res\\images\\test.BMP"

Thank you in advance.
 
Last edited:
I corrected my code like this. I have no issue but I would like to know if I'm going in the right way :

SDManagerGaugeG.cpp :

Code:
char sdmanager_gauge_name[]	= GAUGE_NAME;
extern PELEMENT_HEADER		sdmanager_list;
extern MOUSERECT            sdmanager_list_mouse_rect[];

GAUGE_HEADER_FS700(GAUGE_W, sdmanager_gauge_name, &sdmanager_list, sdmanager_list_mouse_rect, 0, 0, 0, 0);

MAKE_STATIC
(
      cs_background,
      Rec0,
      NULL,
      NULL,
      IMAGE_USE_TRANSPARENCY,
      0,
      0,0
)

PELEMENT_HEADER sdmanager_list = &cs_background.header;

MOUSE_BEGIN( sdmanager_list_mouse_rect, HELP_NONE, 0, 0 )
MOUSE_END
 
That appears to be a solid structure. I cannot emphasize enough to make small additions or changes, and compile often. It is far easier to find and fix one or two small problems immediately than it is to code blindly and then be faced with hundreds of errors... :eek:

The second bit of advice is this: always troubleshoot beginning with the first error in the list. Often you will find that fixing the first error will also fix many of the subsequent errors as well... :D
 
Thank you very much n4gix !

I will be conscientious as you indicated to me.

I have another question, maybe you have the solution.

When my gauge will be finish, I would like to launch this gauge using a sub menu create by simconnect (for creating sub menu using simconnect, it's ok for me I have already do this task using another DLL addon).

Is it possible ?
 
I would guess that it would be possible, although I've never worked with SimConnect, so it's just a guess! :cool:
 
Hello N4GIX !

I think there is a misunderstanding. In fact, I have a DLL module launch by FSX when he start, AND a C++ gauge.

My DLL module is already finish and work fine. My c++ gauge is just a simple gauge who for the moment display only a picture.

Now, what I would like to do, is to launch my C++ gauge from my DLL module.

Do you think it could be done with the method :

loadlibrary() ?

I saw one of your topic who spoke about :

Code:
void FSAPI module_init(void)
{
  // Do mult-gauge initialization here
};

void FSAPI module_deinit(void)
{
  // do multi-gauge de-initialization here
};


BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)	
{													
  switch (dwReason)
  {
  case DLL_PROCESS_ATTACH:
    {
    	dll_instance = hDLL; 
#ifdef _DEBUG
      module_init();
#else
      if (IsExeTampered(dll_instance, true)==exeSuccess)
      {
        module_init();
      }
      else
      {
        return FALSE;
      }
#endif
      break;
    }
  case DLL_PROCESS_DETACH:
    {
      module_deinit();
      break;
    }
  }
  return TRUE;

Is this what we have to do ?

If you know the soft FSPassenger, I would like to do the same thing when you launch the flight and the mini display gauge appear (is launching).

Thank you very much
 
Last edited:
I'm thinking that might be the right path. As I said I've never even thought about what you are asking about.
 
http://archive.msdn.microsoft.com/ESPDrawingGaugesGDI/Release/ProjectReleases.aspx?ReleaseId=1640

Using this as a template can simplify your life considerably. It shows how to use both SimConnect and gauge callback functions in a gauge loaded from the panel cfg. The only time I would say a module is worthwhile is if you are trying to trap SimEvents like AircraftLoaded. In which case you would use GetModuleHandleEx() to determine if the module/gauge is loaded and then just use GetProcAddress() with the string name of the function. It will return a pointer to your function in the module/gauge and that way you can call it...
 
Thank you very much for your answer.

I did a lot of research to launch my gauge (.dll) from my fsx module (.dll).

It seems like I have to use :

- LoadLibrary()
- GetProcAdress()

I'am very lost ... but my code is like this :

Code:
HINSTANCE hGetProcIDDLL = LoadLibrary(L"E:\\FSX\\SDManager\\SDManagerGauge.dll");

			if (hGetProcIDDLL != NULL)
			{
				FARPROC lpfnGetProcessID = GetProcAddress(hGetProcIDDLL, "??");

				if (lpfnGetProcessID == NULL)
				{
					
					// handle the error
					FreeLibrary(hGetProcIDDLL);
				}
			}

As you can see in the GetProcAddress() method I have to put the method I want to call (where I put "??"). This is my issue, I really don't know what method call to launch the gauge ?

module_init() ?

What is the function who control the launch of a gauge (.dll) ? And do I have to do something on the gauge side code ?

Have you an idea ?
 
Last edited:
PHP:
#include "gauges.h"
#include "SDManagerGauge.h"

#define GAUGE_NAME "SDManagerGauge"
#define GAUGEHDR_VAR_NAME gVarGauge
#define GAUGE_W 100

//////////////////////
///CODE DE LA GAUGE///
//////////////////////
char gNomGauge[] = GAUGE_NAME;
extern PELEMENT_HEADER gElementsGauge;
extern MOUSERECT gZoneSouris[];

GAUGE_HEADER_FS700(GAUGE_W, gNomGauge, &gElementsGauge, gZoneSouris, 0, 0, 0, 0);

#define GAUGE_CHARSET DEFAULT_CHARSET
#define GAUGE_FONT_DEFAULT "Courier New"
#define GAUGE_WEIGHT_DEFAULT FW_NORMAL

MAKE_STATIC
(
      sdmanager_background,
      BMP_SDMANAGER_BACKGROUND,
      NULL,
      NULL,
      IMAGE_USE_TRANSPARENCY|IMAGE_BILINEAR_COLOR,
      0,
      0,0
)

PELEMENT_HEADER gElementsGauge = &sdmanager_background.header;
MOUSE_BEGIN(gZoneSouris, HELP_NONE, 0, 0 )
MOUSE_END

//////////
///MAIN///
//////////

/*GAUGE_TABLE_BEGIN()
	GAUGE_TABLE_ENTRY(&gVarGauge)
GAUGE_TABLE_END()*/

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; }

GAUGESIMPORT ImportTable =
{
	{ 0x0000000F, (PPANELS)NULL },
	{ 0x00000000, NULL }
};

GAUGESLINKAGE Linkage =
{
	0x00000013,
	module_init,
	module_deinit,
	0,
	0,
	FS9LINK_VERSION,
	{ (&gVarGauge), 0 }
};

The gauges.h defines make possible to use some functions at the outside of the library (outside of the DLL gauge).

Which function/procedure, we have to call to trigger the gauge's display ?

GetProcAddress(hGetProcIDDLL, "NameOfTheGauge"); ???

It is not by chance that panel.cfg ask the name of the DLL and the name of the gauge like gaugeXX=GAUGEDLL!GaugeName.
 
I'll say it again. You can't do that.

FS has a very complex method it uses to display a gauge that is not part of the gauge code itself. I have no idea where you're getting the impression this is even remotely possible, but honestly... it's not.

Now, I'm certain there are ways to accomplish your end goals... but not with an FS gauge loaded from another DLL. Just isn't going to happen.
 
I think Ed is right. A gauge .dll is nothing but a group of macros and callback functions that are interpreted, linked and instantiated by FS panel builder, following the order present in panel.cfg. You can't instantiate a gauge from a DLL, even though the DLL is loaded at FS startup through dll.xml template.
However, using FSUIPC or SimConnect in that DLL you can build menus and windows to interact with FS, but they won't be "gauges" strictly speaking.

Tom
 
I must assume that mini-display is a gauge and it has to be added to a panel like any other gauge. Otherwise it's a pop-up window.
 
I must assume that mini-display is a gauge and it has to be added to a panel like any other gauge. Otherwise it's a pop-up window.

Ok but if the FSPax mini display should be a win32 classic window, we were able to close it by typing ALT + F4 when focused on.

Just put the mouse on a FSPax mini display corner to see what a mean.

However, a module A can call the display of a module B (the module B could be a mini win32 popup window without FSX in dialogmode).

(sorry for english... i'm french)
 
Certainly... but then it's not a gauge... it's a window.

Then if you're looking to 'call' the window, it's up to you the programmer to provide the interface in the DLL to accomplish that.
 
Last edited:
Hi !

FSPassenger mini display IS a gauge :

The mini display is a trick that is 'impossible' to do for a DLL in FSX, it is now a 'gauge' wich mean there is no display problem (aliasing) and no framerate drop in contrary of FsP2004 normal window.

source : http://www.fspassengers.com/?action=faq&ver=fsx&view=ascii

As the source said, He gave up the normal winform and find the way to launch a gauge from a DLL module.

So it's possible to load a gauge from another DLL module like he does. But the way to do this is obviously a magic trick ...
 
Last edited:
Back
Top