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.

FSX: C-gauge correct events order

Featured Replies

  • Commercial Member

Hi all,When I started testing my gauges in FSX a few weeks ago, I quickly ran into all kinds of strange problems after resizing the FSX window, or hiding and resizing panels. The most troubeling problem I ran into was that my exported variables where destroyed when I resized the window! It became apparent quite quickly that the sequence of events that take place whilst running FSX is different from the sequence in FS2004. This lead to my gauges destroying variables at resize in stead of while unloading the gauges. I decided to map all the FSX events as they occur in sequence, and this are the results of this mapping exercise. I hope this will help other panel developers.This is the correct event sequence (without the opening screen so direct to 2D panel in a saved flight):1. Start-up FSX: PANEL_SERVICE_CONNECT_TO_WINDOW PANEL_SERVICE_PRE_QUERY PANEL_SERVICE_POST_QUERY2. FSX continues to load other gauges3. After msadp32.acm has been loaded PANEL_SERVICE_PRE_INSTALL PANEL_SERVICE_POST_INSTALL PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PANEL_OPEN4. FS starts loading scenery stuff PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_GENERATE PANEL_SERVICE_POST_GENERATE PANEL_SERVICE_PRE_DRAW PANEL_SERVICE_POST_DRAW PANEL_SERVICE_PRE_UPDATE ==> sound starts to work PANEL_SERVICE_POST_UPDATE5. then PRE and POST_UPDATE continu to be called with each tick so I removed those breakpoints6. next call while FS loading bar is slowly increasing: PANEL_SERVICE_PRE_DRAW PANEL_SERVICE_POST_DRAW (etc...)7. when "loading terrain data" is displayed all events stop in the gauges8. loading terrain data is finished ==> back to after is finished PRE/POST DRAW switching9. while wx/traffic, etc is loading etc gauge updating stops again10. End of loading PRE/POST DRAW on each tick11. Change FS window size, only has an effect when the mouse button is released PANEL_SERVICE_PRE_KILL PANEL_SERVICE_POST_KILL PANEL_SERVICE_CONNECT_TO_WINDOW PANEL_SERVICE_PRE_INSTALL PANEL_SERVICE_POST_INSTALL PANEL_SERVICE_DISCONNECT PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_GENERATE PANEL_SERVICE_POST_GENERATE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE etc...12. Hide window (Shift-1 for instance) PANEL_SERVICE_PANEL_CLOSE ==> panel disappears and PRE/POST UPDATE starts again13. re-open panel PANEL_SERVICE_PANEL_OPEN PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE14. This is what happens when FS is closed PANEL_SERVICE_PANEL_CLOSE PANEL_SERVICE_PRE_KILL PANEL_SERVICE_POST_KILL PANEL_SERVICE_DISCONNECT15. Here is what happens when you have loaded your aircraft and then open the FSX aircraft dialog:- when the aircraft dialog is opened and as long as it is open no events are triggered- CANCEL aircraft dialog: update and draw event continu as before- Select the current active aircraft and select OK: PANEL_SERVICE_PANEL_CLOSE PANEL_SERVICE_PRE_KILL PANEL_SERVICE_POST_KILL PANEL_SERVICE_DISCONNECT PANEL_SERVICE_CONNECT_TO_WINDOW PANEL_SERVICE_PRE_QUERY PANEL_SERVICE_POST_QUERYThen all the gauges are loaded ... PANEL_SERVICE_PRE_INSTALL PANEL_SERVICE_POST_INSTALL PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PANEL_OPEN PANEL_SERVICE_PRE_INITIALIZE PANEL_SERVICE_POST_INITIALIZE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_UPDATE PANEL_SERVICE_POST_UPDATE PANEL_SERVICE_PRE_GENERATE PANEL_SERVICE_POST_GENERATE PANEL_SERVICE_PRE_DRAW PANEL_SERVICE_POST_DRAWThen UPDATE and DRAW events start again...And finally open the aircraft dialog, select a different aircraft and click OK: PANEL_SERVICE_PANEL_CLOSE PANEL_SERVICE_PRE_KILL PANEL_SERVICE_POST_KILL PANEL_SERVICE_DISCONNECTThe new panel is loaded.I now initialize my exported variables during the PRE_INITIALIZE event and I destroy them during the SERVICE_DISCONNECT event. I had to move all the exported variables to 1 server gauge because placing them in different gauges again crashed FSX.Bj

simcheck_sig_banner_devteam.jpg

 

Bj

  • 2 weeks later...

Thanks for this info, Bj

  • 2 weeks later...

Thanks Bjorn.One thing that has me puzzled, though, is why you destroy the variables on a PANEL_SERVICE_DISCONNECT...from what I see in your post, the PANEL_SERVICE_DISCONNECT state is also set during a panel resize.How does one now determine that the gauges are being unloaded?CheersBob ScottATP IMEL Gulfstream II-III-IV-V L-300Santiago de Chile

Bob Scott | President and CEO, AVSIM Inc
ATP Gulfstream II-III-IV-V

Sys1 (MSFS20+24/XPlane12+11): AMD 9800X3D, water 2x240mm, MSI MPG X670E Carbon, 64GB GSkill 6000/30, nVidia RTX4090FE
Alienware AW3821DW 38" 21:9 GSync, 2x4TB Crucial T705 PCIe5 + 2x2TB Samsung 990 SSD, EVGA 1000P2 PSU, 12.9" iPad Pro
Thrustmaster TCA Boeing Yoke, TCA Airbus Sidestick, Twin TCA Airbus Throttle quads, PFC Cirrus Pedals, Coolermaster HAF932 case

Sys2 (P3Dv5/v4): i9-13900KS, water 2x360mm, ASUS Z790 Hero, 32GB GSkill 7800MHz CAS36, ASUS RTX4090
Samsung 55" JS8500 4K TV@60Hz,
3x 2TB WD SN850X 1x 4TB Crucial P3 M.2 NVME SSD, EVGA 1600T2 PSU
Fiber link to Yamaha RX-V467 Home Theater Receiver, Polk/Klipsch 6" bookshelf speakers, Polk 12" subwoofer, 12.9" iPad Pro
PFC yoke/throttle quad/pedals with custom Hall sensor retrofit, Thermaltake View 71 case, Stream Deck XL button box

Sys3 (DCS/P3Dv4/ATS/ETS): AMD 7800X3D, MSI MPG X870E Carbon, Noctua NH-D15S, 64GB GSkill 6000/30, EVGA RTX3090
Alienware AW3420DW 34" 21:9 GSync, Corsair HX1000i PSU, 4TB Crucial T705 PCIe5 + 2TB Samsung 970Evo Plus,
TM TCA Officer Pack
, Saitek combat pedals, TM Warthog, TM RS300 FF wheel/pedals, Coolermaster HAF XB case

Keep in mind, you can, if you wish, replace this:GAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&gaugehdr_dsd_xml_sound3)GAUGE_TABLE_END()with this:void FSAPI module_init(void) { } void FSAPI module_deinit(void) { }BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved) { return TRUE;}GAUGESIMPORT ImportTable = { { 0x0000000F, (PPANELS)NULL }, { 0x00000000, NULL } };GAUGESLINKAGE Linkage = { 0x00000013, module_init, module_deinit, 0, 0, FS9LINK_VERSION, { (&gaugehdr_dsd_xml_sound3), 0 }};Certainly a lot more verbose, but the module_init and module_deinit functions will only ever be called once each, so you don't have to worry about the callback messing up your shared variables.Doug

  • Commercial Member

Hi Bob,Well that is exactly the problem with FSX !I haven't tried the code Doug provided in his reply and from what I understand of it it does exactly that what you want. But in my case using the DISCONNECT and the PRE_INITIALIZE events works just fine.Kind regards,Bj

simcheck_sig_banner_devteam.jpg

 

Bj

Hi Guys,Reading all of this: PLEASE, let nobody complain anymore that XML gauges are difficult to make ....LOL :-)Cheers, Rob

Thanks Doug...a faint glimmer of a clue light is barely perceptible through the fog now.CheersBob ScottATP IMEL Gulfstream II-III-IV-V L-300Santiago de Chile

Bob Scott | President and CEO, AVSIM Inc
ATP Gulfstream II-III-IV-V

Sys1 (MSFS20+24/XPlane12+11): AMD 9800X3D, water 2x240mm, MSI MPG X670E Carbon, 64GB GSkill 6000/30, nVidia RTX4090FE
Alienware AW3821DW 38" 21:9 GSync, 2x4TB Crucial T705 PCIe5 + 2x2TB Samsung 990 SSD, EVGA 1000P2 PSU, 12.9" iPad Pro
Thrustmaster TCA Boeing Yoke, TCA Airbus Sidestick, Twin TCA Airbus Throttle quads, PFC Cirrus Pedals, Coolermaster HAF932 case

Sys2 (P3Dv5/v4): i9-13900KS, water 2x360mm, ASUS Z790 Hero, 32GB GSkill 7800MHz CAS36, ASUS RTX4090
Samsung 55" JS8500 4K TV@60Hz,
3x 2TB WD SN850X 1x 4TB Crucial P3 M.2 NVME SSD, EVGA 1600T2 PSU
Fiber link to Yamaha RX-V467 Home Theater Receiver, Polk/Klipsch 6" bookshelf speakers, Polk 12" subwoofer, 12.9" iPad Pro
PFC yoke/throttle quad/pedals with custom Hall sensor retrofit, Thermaltake View 71 case, Stream Deck XL button box

Sys3 (DCS/P3Dv4/ATS/ETS): AMD 7800X3D, MSI MPG X870E Carbon, Noctua NH-D15S, 64GB GSkill 6000/30, EVGA RTX3090
Alienware AW3420DW 34" 21:9 GSync, Corsair HX1000i PSU, 4TB Crucial T705 PCIe5 + 2TB Samsung 970Evo Plus,
TM TCA Officer Pack
, Saitek combat pedals, TM Warthog, TM RS300 FF wheel/pedals, Coolermaster HAF XB case

>Reading all of this: PLEASE, let nobody complain anymore that>XML gauges are difficult to make ....LOL :-)XML gauges are difficult to make. :((yes I am a C++ dude) :-hahHappy coding! :-beerchugEtienne :-wave

  • Commercial Member

Have to agree with Badderjet, C++ gauges are really not that difficult once you know how they work. I always set up the basic gauge design in EasyGauge (which is by now completely out of date though) and then clean up the code by hand, and add functionality. To me XML is much less transparent, so it really depends on what you are used to use... Bj

simcheck_sig_banner_devteam.jpg

 

Bj

>C++ gauges are really not that difficult once you know how they work.XML guys might say the same about XML *:-*, but I do agree with you :-lol and I...>so it really depends on what you are used to use... ... second that for sure. :) Depends on your prior knowledge, the use of the gauge etc well we've already had the discussion I believe... ;)Cheers,Etienne

Nice work.

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.