P3D v4 Gauge DLL 64 bit &VS2019

Greetings to all!
I have Prepar3D v4.5.13 and VS2019 Community v16.4.5.
I'm trying to create a C++ gauge based on SDK examples without SimConnect, platform Debug x64. Failure!
The first problem is that the SDK description requires placing the device DLL in the Prepar3D\gauges folder in the root directory. But this leads to a fatal error in the simulator.
If the device is not placed in the airplane Panel folder, there is no error. True, the device is not visible, but this is the second problem.
I ask for help while on the first problem.

Thanks!
 
Another problem is that the plug-in default DLL gauges are not displayed in the new gauges window. At the same time, xml devices are output well. The screen shows my window with three connected gauges, the first of them is mine. As you can see, only compas is displayed. A fragment of the configuration panel:

[Window04]
size_mm=440,440
window_size=0.4
position=5
Background_color=1,0,0
visible=1
ident=COMPASS_PANEL
zorder=5

gauge00=Sht_P3Dv45_SimConnect_TabloCoord!Sht_TabloCoord,10,10,200,200 // My gauge
gauge01=Piper_J3Cub!compass, 290, 21 // xml gauge
gauge02=AC111x64!GPSint, 294,211,15,18 // DLL gaude

Does anyone know about this problem?
 

Attachments

And the final problem is the C++ code of the device.
The DLL project in VS2019 Debug x64 was created automatically with precompilation.
Project Included files:
CGaugeDeclarations.h
CGaugeDeclarations.cpp
pch.h
pch.cpp.
In resource files:
resources.h
resource.rc with one bmp background image.

The contents of the files are listed below.
 
Last edited:
CGaugeDeclarations.h
--------------------------------------
#pragma once
#include "pch.h"

#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))
#ifndef VS_VERSION_INFO
#define VS_VERSION_INFO 0x0001
#endif
 
CGaugeDeclarations.cpp
------------------------------------
#pragma once
#include "pch.h"
#include "CGauge_Declarations.h"
#include "resource.h"

#define GAUGE_NAME "Sht_TabloCoord"
#define GAUGEHDR_VAR_NAME gaugehdr_ShtCPribor
#define GAUGE_W 400
#define GAUGE_H 400

// Set up gauge header
char ShtCPribor_gauge_name[] = GAUGE_NAME;
extern PELEMENT_HEADER ShtCPribor_list;
extern MOUSERECT ShtCPribor_mouse_rect[];

//{228c9873 - f6c8 - 41cd - a768 - 35a7dc918511}
static const GUID gauge_guid = {0x228c9873, 0xf6c8, 0x41cd, {0xa7, 0x68, 0x35, 0xa7, 0xdc, 0x91, 0x85, 0x11}};

GAUGE_HEADER_FS1000 (
GAUGEHDR_VAR_NAME,
GAUGE_W,
ShtCPribor_gauge_name,
NULL,
ShtCPribor_mouse_rect,
0, // Callback
0L,
0L,
gauge_guid,
0,
0,
0,
0,
0);

FAILURE_RECORD ShtCPribor_fail[] =
{
{FAIL_SYSTEM_ELECTRICAL_PANELS, FAIL_ACTION_NO_DRAW},
{FAIL_NONE, FAIL_ACTION_NONE}
};

MAKE_STATIC
(
ShtCPribor_background,
IDB_BITMAP1,
NULL,
NULL,
IMAGE_USE_TRANSPARENCY,
0,
0, 0
)

MOUSE_BEGIN(ShtCPribor_mouse_rect, HELPID_CONCORDE_TEMPERATURE_TOTAL, 0, 0)
MOUSE_END

#undef GAUGE_NAME
#undef GAUGEHDR_VAR_NAME
#undef GAUGE_W
#undef GAUGE_H

///////////////////////////////////////////////////////////////////////////////////////////
extern GAUGEHDR gaugehdr_ShtCPribor;
void FSAPI module_init(void) {}
void FSAPI module_deinit(void) {}

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

GAUGESLINKAGE Linkage =
{
0x00000013,
module_init,
module_deinit,
0,
0,
FS9LINK_VERSION, {
&gaugehdr_ShtCPribor,
0 }
};
 
The project compiles normally. But the device is not displayed in the simulator. Maybe there is an error in the code?
 
Hello, Gav-Kot.
First of all. Have you tried to convert SDK example project "CGaugeSample" to Visual Studio 2019? Does it works? I mean can you load and see gauges from that example in your test airplane? have you also copied debug information (*.pdb) file with the dll before start debuger?
 
Last edited:
Hi, Prepar3DGuy!
Yes, I tried it. SDK projects in VS2019 do not work. I had to rework them thoroughly to compile them, but I couldn't compile them. So I took the FSX project as a basis, but the device is not displayed in the simulator.
 
Ok. I have found error in your code.
GAUGE_HEADER_FS1000 (
GAUGEHDR_VAR_NAME,
GAUGE_W,
ShtCPribor_gauge_name,
NULL,
ShtCPribor_mouse_rect,
0, // Callback
0L,
0L,
gauge_guid,
0,
0,
0,
0,
0);
In the fourth argument you must pass a pointer to the first drawing element in the list of elements.
C++:
GAUGE_HEADER_FS1000(
    GAUGEHDR_VAR_NAME,
    GAUGE_W,
    ShtCPribor_gauge_name,
    &ShtCPribor_list,
    ShtCPribor_mouse_rect,
    0, // Callback
    0L,
    0L,
    gauge_guid,
    0,
    0,
    0,
    0,
    0
)

MAKE_STATIC (
    ShtCPribor_background,
    IDB_BITMAP1,
    NULL,
    NULL,
    IMAGE_USE_TRANSPARENCY,
    0,
    0, 0
)

PELEMENT_HEADER ShtCPribor_list = &ShtCPribor_background.header;
Your mistake was to pass NULL instead of a pointer. As a result Prepar3D's module panel.dll try to load gauge from your dll and receive "Access violation" exception. Crash!
 

DragonflightDesign

Resource contributor
Also: unless you are considering using serialization for multi-cockpit gauges, I'd use the FS900 header rather than the FS1000 header. It's simpler.
 
More information on this issue. Gauges, compiled by VS 2019, are not displayed. But the same devices, compiled by VS2017, are displayed and work normally.
Think.
Thanks for the help Prepar3DGuy!
 
So, the preliminary result. For information, can be whom will help.
1. The C-Gauge dll from VS2019 are not displayed in any way.
2. C-Gauge dll from the VS2017 are displayed when they are placed in the root directory of the simulator's Gauge or in the panel folder.cfg. Installation through the add-on.xml doesn't work.
3. The problem with displaying resources in VS2019 remained, not solved.

For now I recommend using VS2017 and placing the C-Gauge in the panel.cfg folder.
 
VS2019 Studio for traffic works well, because it does not use resources.
Checked the installation through the add-on.xml of the following categories:
traffic bgl from SDK;
traffic C-dll;
SimObjects;
Scenery.
Connect and work well. As an example, the ship in the C-traffic of the vs2019 dll.

Shot_028.jpg
 
Greetings to all!
Very good news!
Update v 16.4.6 for VS2019 has been released. After installing this update, the C-gauges started working!
In the screenshot, the Control_Surfaces device from the SDK V4.5.13 kit.
We can assume that the problem has been solved, and the issue of devices is closed.
There is still a problem with object animation.

With respect!

Shot_050.jpg
 
Top