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

FSXA IGaugeCDrawable flow?

JB3DG

Resource contributor
Messages
1,325
Country
southafrica
Hi guys

So...I have been moving further with DirectX gauges and have run into some limitations....I may be able to get past them using the IGaugeCDrawable system however with it being completely undocumented im uncertain as to the steps that are necessary for it. Anyone here know how it works?

Thanks
JB
 
Gee....Doesnt anyone know how it works? Or is it something that no one wants to share?
 
I'm uncertain what you hope to accomplish here. That is a method to interface with an external .dll such as the fs9gps.dll.
 
Its like Bill says. IGaugeCDrawable is the base class that instantiates when you build a <CustomDraw> structure in an XML gauge, and is also a component of IGaugeCCallBack base class. You shouldn't need it at all if you are coding in C++ only.

Tom
 
Hmmm...I think I have a bare notion on what you intend to do.
Maybe something like this?:

In a C++ gauge:

-Define a MAKE_STATIC macro that "loads" a bitmap resource of known size (its contents wouldn't matter, could be a pure black image).
-Create instances of IPanelCCallBack,IPanelAircraftCCallBack,IGaugeCCallBack, IGaugeCDrawable and IGaugeCDrawableDrawParameters. These classes might be located in a module dll or even declared in the same gauge.
-Force a call to IGaugeCDrawable Draw() function, which is supposed to pass a PIMAGE pointer to the callback.
-Within the Draw() function, fill the PIMAGE pointer with data from your DirectX buffer.

Am I guessing right?

Anyway, if you want a good example on how to deal with IGaugeCDrawable methods, just download and inspect DLL for XML traffic radar / TCAS posted by Doug Dawson on the downloads section.
Despite it is focused on a C++ to XML interfase, it could be ported to a pure C++ platform (which doesn't seem to be an easy task)

Tom
 
Aha i was looking for that file but it went missing from AVSIM. Thanks a bunch. That should sort out everything for me.
 
How to get the HDC of the Gauge

Hello Everyone,

I am new at the Forum. I have read the threads, is there a way to get the HDC that the Draw method of IGaugeCDrawable is using to draw their bitmaps?

JB, have you found the HDC using this approach? (I don't want to start with Hooks yet).

Thanks

Federico Sucari
 
When you define the Draw Method of your IGaugeCDrawable class, you just use the HDC thats listed in the parameters.

But if you have no intention of using a XML custom draw and just want to do a GDI+ gauge then the ESP GDI+ example shows you how it is done.
 
Thanks JB for your prompt reply.

Let's say you create instances of IPanelCCallBack, IPanelAircraftCCallBack (and so on...), and then you call the IGaugeCDrawable Draw() function.

HDC is is a parameter of the IGaugeCDrawable Draw() function which I don't know? Am I correct? I am trying to get the value of the HDC..
 
Last edited:
Taken from the Traffic Radar sample mentioned earlier in this thread:

Code:
bool	GdiPlusRadar::Draw(HDC hdc, double true_hdg, BOOL antialias)
{

if(hdc==NULL)
 return false;
	
SAFE_DELETE(m_graphics);
 m_graphics = new Graphics(hdc);

if(m_graphics==NULL)
 return false;
}
 
Thanks JB.

I am trying to draw on a 3rd Party gauge (Pure C++), and I am trying to get it's HDC.

With panel_get_registered_c_callback() (and all these set of functions), you can create interfaces for a gauge methods (I tried with fs9gps and worked).

My question is, let's say that I can create interfaces of a Gauge through the above mechanism, how do you get its HDCs?

In your example, who instatiates hdc variable?

Thanks!
 
Last edited:
What I am trying to discover is a method to interface with an external DLL, and also get their HDCs.
 
Thanks JB.

I am trying to draw on a 3rd Party gauge (Pure C++), and I am trying to get it's HDC.

With panel_get_registered_c_callback() (and all these set of functions), you can create interfaces for a gauge methods (I tried with fs9gps and worked).

My question is, let's say that I can create interfaces of a Gauge through the above mechanism, how do you get its HDCs?

In your example, who instatiates hdc variable?

Thanks!

There is no guarantee you can obtain an active HDC for a third-party gauge. It would depend on the method being used to render said gauge.
 
Thanks for your reply WarpD.

Are you suggesting that the only way could be Hooking GDI+, or Directx? (or whatever engine/APIs the third-party is using)

Or within the FSX SDK environment are there any workarounds?

Thanks

Federico
 
There's no guarantee you could control the point of render without knowing exactly when the gauge was drawn, which is unlikely to be available.

A DirectX gauge has no HDC by default, and obtaining one is time-intensive.
A GDI+ gauge can obtain an HDC, but only the GDI+ gauge knows when it's HDC is physically valid.

I have no idea what you're really trying to make, but this isn't like subclassing a window by any stretch of one's imagination. I'm not saying this is impossible, but the probability of accomplishing it and it being a good performer CPU-wise is rather low in my opinion.
 
Thanks WarpD.

When you say:

There's no guarantee you could control the point of render without knowing exactly when the gauge was drawn, which is unlikely to be available.

What are you meaning with this? Could you explain it?
 
Gauges are rendered when FS tells a gauge to render, that's it. The only way to know when that happens is to either be FS (the one sending the render request) or be the gauge (the one recieving the render request).

The render request is send via the gauge's callback routine. You would have to hijack that callback routine to see the request. Hijacking that routine could have severe performance impact as it's called for every frame in FS. As example... to ensure 20 frames per second, all rendering has to be completed in less than 50 milliseconds, that's not just one gauge's rendering... everything.
 
You could possibly create pointers to the HDCs created during the callback like in the ESP GDI+ example and then share those pointers through your dlls. If im understanding correctly thats what you are trying to do?
 
Last edited:
Well...hijack might be the wrong word but isnt that how the ESP GDI+ gauge works?

@federicosucari you will have to make clear what you are wanting to do here as i am not entirely sure i understand you.

None the less, if you just want to draw using GDI+ then the ESP GDI+ example is the way to go.

If you want to use DirectX, I am afraid that it is proving to be rather tricky. I can supply you with a way to hook into FSX's IDirect3DDevice9 instance but to draw to a child window(which is what all panel cfg entries create) is proving difficult to do. If you want to join me on figuring it out be my guest.
 
Back
Top