May 23, 200719 yr After 8 solid hours of testing and pulling out my hair, I have finally localized the cause of the CTD when loading the default B206 (and only the B206) after my aircraft.In my fuel valve gauge on the main panel, I define an event handlerCODE void CALLBACK EventHandler (ID32 event, UINT32 evdata, PVOID userdata){ if (event == KEY_PAUSE_TOGGLE) { // User has PAUSED the sim bPauseToggle = !bPauseToggle; } if (event == KEY_SOUND_TOGGLE) { // User has toggled sound bSoundToggle = !bSoundToggle; }}void CALLBACK C_GAUGE(Gcb_)(PGAUGEHDR pgauge, SINT32 service_id, UINT32 extra_data){ PCHAR pParams = NULL; switch (service_id) { case PANEL_SERVICE_PRE_INITIALIZE: if ( pgauge != NULL ) { register_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler, 0); case PANEL_SERVICE_PRE_KILL: unregister_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler, 0); break;}And when I comment out the handler and the register and unregister calls, FSX does not crash.Anyone have any suggestions? Does this sound like a bug since the code did work? Or, do you see something I'm doing wrong here?Patrick
May 23, 200719 yr Try moving the register event to PANEL_SERVICE_CONNECT_TO_WINDOW, and the unregister event to PANEL_SERVICE_DISCONNECT. Alternatively, put them in module_init and module_deinit.PRE_INITIALIZE and PRE_KILL get executed when the user switches between windowed and full-screen, and when the user moves or re-sizes a panel window.Doug
May 23, 200719 yr Doug,>Try moving the register event to>PANEL_SERVICE_CONNECT_TO_WINDOW, and the unregister event to>PANEL_SERVICE_DISCONNECT. OMG, you are a genius! It worked!!!! Why?>Alternatively, put them in module_init and module_deinit.I will try this too see if this works too, but I'm guessing it will given your suggestion.>PRE_INITIALIZE and PRE_KILL get executed when the user>switches between windowed and full-screen, and when the user>moves or re-sizes a panel window.Ok, I open FS in a window (vs. full screen) switch from VC to 2D view, then switch to the default, and it locks up. There was never a window resize, or window move. However, it did not lock until I clicked the window, so maybe that triggered the pair.You must have spent hours analyzing when those get called.May you win the lottery this coming weekend!Patrick
May 28, 200719 yr I spoke to soon :(Basically, moving the registration allows other aircraft to be loaded, but the Event Handler is never called.Also, if fact, if done the other way, ALL other aircraft crash after being loaded, not just the default B206 as I originally thought.Moving it to the module_init etc. also compiles, but again the handler is never actually called, although loading of other aircraft does not cause a crash.So, not sure what to try now.Patrick
May 28, 200719 yr Finally solved this one totally.The secret was using: PANEL_SERVICE_PANEL_OPEN PANEL_SERVICE_PANEL_CLOSEimagine that.
May 29, 200719 yr Moderator I'm happy you got it sorted out.There are so MANY of the PANEL_SERVICE_xxx cases and not a single one of 'em is actually explained anywhere in the SDK, so we all have to work on the "Principle of Guess and by God..." *:-* "Every rule ever made has at least as many exceptions as there are people living..." :) Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
May 29, 200719 yr Yes, it was not apparent even from looking at the order they are called when different events happen in the sim.But, it seems they are making more sense to me now. It really would be nice if they were documented somewhat.Patrick
Create an account or sign in to comment