Sign in to follow this  
Guest Patrick_Waugh

StoreInstanceHandle() what?

Recommended Posts

Arne,I notice that you do this:void FSAPI gauge_cb( PGAUGEHDR pgauge, int service_id, UINT32 extra_data ){ static HWND fswnd = NULL; switch(service_id) { CASE PANEL_SERVICE_PRE_INSTALL fswnd = FindWindow("FS98", NULL); StoreInstanceHandle( (HINSTANCE)extra_data ); InitDirectInput( fswnd ); SetAcquire( fswnd ); break; }}First, I notice that you can get the window handle like this: if ( FAILED( hr = InitDirectInput( GetModuleHandle(NULL) ) ) ) { return(0); }or SetAcquire( GetModuleHandle(NULL));when you make the calls, like above, so no need to base it on the "FS98", or even store it.But, I have a question... what the heck is this StoreInstanceHandle( (HINSTANCE)extra_data ); call doing, and what is "extra_data"?Thanks

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Correction, you can't get the window handle like that, only a HMODULE (but then you knew that no doubt).Anyway, DirectInput is much easier than DirectSound, and I have it working now, but still wondering what the extra_data and function do.

Share this post


Link to post
Share on other sites

extra_data is one of the parameters passed to the callback function. Check the definition of PANEL_SERVICE_PRE_INSTALL in GAUGES.H. The various values are outlined there as comments.Doug

Share this post


Link to post
Share on other sites

Actually, I find the comment on the PANEL_SERVICE_POST_INSTALL a bit on the confusing side, since that is where most folks read any so-called "5th parameter information" that one might wish to pass to the gauge from the panel.cfg entry.Am I correct to assume then that - absent any such 5th parameter data - that the "extra_data" will still contain the resource_handle?

Share this post


Link to post
Share on other sites

>Actually, I find the comment on the>PANEL_SERVICE_POST_INSTALL a bit on the confusing side, since>that is where most folks read any so-called "5th parameter>information" that one might wish to pass to the gauge from the>panel.cfg entry.>>Am I correct to assume then that - absent any such 5th>parameter data - that the "extra_data" will still contain the>resource_handle?Not sure what it will contain on POST_INSTALL - nothing is noted in gauges.h on that line. Sounds like an interesting experiment...Keep in mind that the parameter information you mention is at pgauge->parameters, not extra_data.Doug

Share this post


Link to post
Share on other sites

OK, so I was on drugs this afternoon... :-eek POST_INSTALL will get the resource handle as the extra_data value. Full Stop.Doug

Share this post


Link to post
Share on other sites

>Not sure what it will contain on POST_INSTALL - nothing is>noted in gauges.h on that line. Sounds like an interesting>experiment...>Keep in mind that the parameter information you mention is at>pgauge->parameters, not extra_data.My gauges.h file shows the same comment for both PRE and POST_INSTALL:#define PANEL_SERVICE_PRE_INSTALL 2 // extra_data = resource_handle#define PANEL_SERVICE_POST_INSTALL 3 // extra_data = resource_handleActually, I've never fully comprehended what 'magic' is happening in the gauges.h file. I'd always assumed that "extra_data" and "parameters" were referring to the same thing. I guess I just know enough to be a bit less dangerous than a complete ignoramous! *:-*

Share this post


Link to post
Share on other sites

Resources are still a bit of magic for me... so I'm not entirely sure how to use a resourc_handle, but reminding me about the 5th parameter thing helped.Anyway, turned out it was not necessary to get DirectInput working for the keyboard or joystick. But it gives me an idea of an easy way to have the user be able to set the key which will actuate a particular gauge. They can pass it in the 5th parameter. Now where is that code to read the 5th parameter again.... haha =)

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