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

P3D - Question about gauge development.

Messages
9
After working with the samples from the Prepar3d SDK, I wanted to stand up a new gauge project but have been unable to build even the smallest conceivable project.
Presently I am using Visual Studio 2022, the Prepar3d SDK V5, and created one simple C++ file containing this:


#include "Header.h"
#include "gauges.h"


#define GAUGE_W 100

// Define a minimal gauge callback that does nothing
void FSAPI MinimalGaugeCallback(PGAUGEHDR pgauge, SINT32 service_id, UINT_PTR extra_data)
{

}

// Set up the minimal gauge header
GAUGE_HEADER_FS700(GAUGE_W, "Minimal Gauge", NULL, NULL, MinimalGaugeCallback, 0, 0, 0);


and the Headers.h header file containing this:

#pragma once
#define VERSION_MAJOR 1
#define VERSION_MINOR 0
#define VERSION_BUILD 0

// magic to get the preprocessor to do what we want
#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))

At this point I am getting a: LNK1104 cannot open file 'gauges.lib'
Again, what I am trying to achieve is to build an empty (or as empty as possible) gauge dll, with the minimum required code as opposed to reusing the sdk samples.
Any help or guidance is much appreciated.
 
I think this is what I was looking for:

#include <windows.h>
#include <stdio.h>
#include "gauges.h"

// Define our own minimal callback parameters structure
struct GaugeCallbackParameters {
DWORD dwReason;
DWORD dwParam1;
DWORD dwParam2;
};

// Global variables
GaugeCallbackParameters* g_pGaugeParams = NULL;

// Function prototypes
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
BOOL CALLBACK GaugeCallback(GaugeCallbackParameters* pParams);

// DLL entry point
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}

// Gauge callback function
BOOL CALLBACK GaugeCallback(GaugeCallbackParameters* pParams) {
g_pGaugeParams = pParams; // Store the parameters for later use

switch (pParams->dwReason) {
case 0: // GAUGE_INIT equivalent
// Initialize your gauge here
break;
case 1: // GAUGE_DRAW equivalent
// Draw your gauge here
break;
case 2: // GAUGE_UPDATE equivalent
// Update your gauge here
break;
case 3: // GAUGE_MOUSE equivalent
// Handle mouse events here
break;
case 4: // GAUGE_DESTROY equivalent
// Clean up your gauge here
break;
}
return TRUE;
}

// Gauge initialization function
extern "C" BOOL __declspec(dllexport) GaugeInit(void* pInitParams) {
// Perform any one-time initialization here
return TRUE;
}

// Gauge deinitialization function
extern "C" BOOL __declspec(dllexport) GaugeDeinit(void) {
// Perform any cleanup here
return TRUE;
}
 
Nope, that code's pretty much unworkable.

A gauge callback is not defined with a struct being passed to it. Your approach just doesn't work. You have defined the 3 variables being passed as all being DWORD values and they are actually defined as a PGAUGEHDR , an SINT32 , and a UINT_PTR. Subsequently you then use the PGAUGEHDR variable as a "dwReason" DWORD and that just doesn't work. At all.

I am uncertain why your original code was looking for a gauges.lib file... never seen one used in any gauges I've written.

Also, I see no actual gauge declaration in your code. What kind of gauge is it? ICON? IMAGE? SLIDER? Many choices to chose from.
 
Nope, that code's pretty much unworkable.

A gauge callback is not defined with a struct being passed to it. Your approach just doesn't work. You have defined the 3 variables being passed as all being DWORD values and they are actually defined as a PGAUGEHDR , an SINT32 , and a UINT_PTR. Subsequently you then use the PGAUGEHDR variable as a "dwReason" DWORD and that just doesn't work. At all.

I am uncertain why your original code was looking for a gauges.lib file... never seen one used in any gauges I've written.

Also, I see no actual gauge declaration in your code. What kind of gauge is it? ICON? IMAGE? SLIDER? Many choices to chose from.
I am sorry for providing nonsense, it was really an attempt to start from zero as opposed to be using one of the provided samples. I understand this is incomplete and won't run as gauge. My plan also was to avoid the macros (make_icon, make_sprite etc.) and paint the gauge bitmpas via gdi. I had some succes with that previously.
 
If there is nothing that defines an actual gauge, how do you add it to an aircraft's panel.cfg file? Is there a gauge element I'm unaware of that's perhaps undocumented that allows you to define a gauge that has absolutely no elements that define it? I'm probably coming across aggressively, and I don't mean to do so... I just don't see how you can create a gauge that has no elements at all. As for GDI+, I do ton of GDI+ gauge creation and even then, there's at least one element required to define a gauge referenced in an aircraft's panel.cfg.
 
@DragonflightDesign: Thank you for the link !!!!!
@WarpD, Thank you for your response. What you write makes a lot of sense. I am aware that the posted code is useless but please understand, this was an attempt to arrive at the smallest possible / reusable solution (as opposed to modifying the existing SDK samples from Prepar3d) for a gauge as I will have to build several gauges in the coming month.
>"If there is nothing that defines an actual gauge, how do you add it to an aircraft's panel.cfg file?"
You are right, this is exactly what I am trying to wrap my head around.
 
I suggest you read Dai's programming guide, especially the part about making a multi-gauge project.
 
Back
Top