Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Redundant code?

Featured Replies

Have seen people doing this:

case PANEL_SERVICE_PRE_INITIALIZE:if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}bg_element = (PELEMENT_STATIC_IMAGE)pgauge->elements_list[0];GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");break;case PANEL_SERVICE_PRE_KILL:MGaugeSound = GetModuleHandle("GaugeSound");if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");(TerminateSounds)();FreeLibrary(MGaugeSound);break;

But seems like once you have loaded the DLL and located the functions, that you do not need to repeat this. So, the above could be:

case PANEL_SERVICE_PRE_INITIALIZE:if (MGaugeSound == NULL) {MGaugeSound = LoadLibrary("GaugeSound");}bg_element = (PELEMENT_STATIC_IMAGE)pgauge->elements_list[0];GaugePlaySound = (TGaugePlaySound)GetProcAddress(MGaugeSound,"GaugePlaySound");GaugeStopSound = (TGaugeStopSound)GetProcAddress(MGaugeSound,"GaugeStopSound");TerminateSounds = (TTerminateSounds)GetProcAddress(MGaugeSound,"TerminateSounds");break;case PANEL_SERVICE_PRE_KILL:(TerminateSounds)();FreeLibrary(MGaugeSound);break;

Also, what's with this line?:

bg_element = (PELEMENT_STATIC_IMAGE)pgauge->elements_list[0];

Is this just a short-cut?Thanks,Stick

A lot of the examples I've seen can probably use some serious cleaning up and optimization, not to mention that a hefty dose of comments would be nice :).Warning: lines using pre-processor macros which run galore in gauge writing can lead to mysterious and hard to find bugs.I cache most global values, including handles at it seems redundant to read them at every cycle since they do not change and you want to do everything to increase frame rates.The only issue I see is that if you have multiple shared DLLs with different instances but share the code, so that you would need to check the current instance and handle inside the main gauge callback function.As far as the element question, it's a reference to a paintable bitmap (one created by MAKE_STATIC, with the DIB image flag specified). That's normally the second item after your background image in the element list, but it doesn't have to be. You need to use the proper element offset in the list though. If you try to paint on an image without the DIB flag and use the wrong offset in the element list, you usually end up with a crash. Using a debugger helps you ensure you get the right item.If you lookup the flight map example in the SDK samples, it shows you how to do GDI+ drawings on a static bitmap.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.