Jump to content
Sign in to follow this  
glassman2005

How to know when cockpit first appears?

Recommended Posts

Is there any way to know when the cockpit view has actually first come up on the screen when a flight is loaded? In tracing the events that come through the main callback, I've noticed that most (if not all) of the events start streaming through a gauge's callback long before the cockpit has actually appeared on the screen (in other words, the callback has started happening even while the FS progress bar is saying things like "loading terrain", etc). Is there a way to know after we've reached 100% and the panel is finally fully displayed?

Share this post


Link to post
Share on other sites

I would have thought that you wouldn't get an instance of PANEL_SERVICE_PRE_DRAW until the gauge was actually about to hit the screen. If this is not the case, you could try monitoring the return value from the is_panel_window_visible_ident function.Doug

Share this post


Link to post
Share on other sites

I would have thought the same thing. Now that you say this, I'm going to re-test this to see if perhaps I've got some kind of bug that's allowing control to fall through one of my case conditions in the callback. It's acting like there's a "break;" statement missing, but I figured I'd have experienced other problems if that was the case. Neverthless, I've already checked for missing "break"s several times, but I won't discount that it's something I've done! Actually, now that I think about it, one of my tests was to put the breakpoint right on the "switch" statement, at the very top of the callback, and I definitely got 10's and 11's during the "loading" phase. (10 and 11 are panel_service_pre_draw and panel_service_post_draw, respectively).It's also odd that panel 0 (IDENT_MAIN_PANEL) indicates a "visible" state (value == 1) when calling is_panel_window_visible_ident(IDENT_MAIN_PANEL). Really strange.

Share this post


Link to post
Share on other sites

If you were missing a break statement, I don't think the gauge would compile. Been there...You could try watching for a change in FS time, although this approach would also require a time out, in the event the flight was started paused or in slew mode.What is it you're trying to do (or not do)? Doug

Share this post


Link to post
Share on other sites

I'm trying to take a snapshot of a section of the panel window, but I can't do that unless I have a DC to the panel window. The panel window doesn't have a valid DC until after it's been undocked and re-docked at least once, so I've been trying unsuccessfully to undock the panel window momentarily and redock it through code, but the undocking doesn't happen, possibly because my attempt at undocking is happening before the windows are fully built.

Share this post


Link to post
Share on other sites

Hmm... Keep trying the undock every half second or so until the return value from the function (SetParent?) indicates that it has succeeded?If you get desparate, I have some desparate suggestions you could try. Let me know...Doug

Share this post


Link to post
Share on other sites

Yes, I'm using SetParent:originalParent = SetParent(panelWindow, NULL);The return value of SetParent is supposed to be the hwnd of the original parent, and it's coming back non-null when it executes, so it appears to be doing something, but there's no change in the status of the main panel. I may need to decipher the wm_command message sent to the window from the popup menu with the undock command in it. What are you desparate suggestions?

Share this post


Link to post
Share on other sites

Well, it strikes that you can't actually close a window until it has been opened. So what happens if you create another panel window. On this window, you will have one gauge. This gauge will do two things. In panel_service_pre_draw (maybe the second or third iteration of panel_service_pre_draw) it will close this new window. In panel_service_pre_kill, it will set a flag that will allow your current project gauge to undock its window. An ugly solution that of course introduces another window that the enterprising user can mess up...Another, completely off the wall suggestion... Cobble together a quick and dirty xml gauge that does nothing more that assign a non-zero value to an L:Var. See if waiting until your gauge can read this value gets you anywhere. I seem to recall some recent discussion about limiting xml gauge calculations to when the gauge is visible. Sorry, I don't recall the thread...One last thing. Are you certain that SetParent will work in this context? I ask because I messed around with it, along with SetWindowLong, a while back. I got absolutely no where, which I chalked up to having absolutely no idea what I was doing. Given that you are also having problems with it, I now begin to wonder.FSUIPC does have a "ready to fly" flag, which would likely give you the time point you need.Doug

Share this post


Link to post
Share on other sites

I'll mess around with some of your suggestions, and I'm playing with some other ideas too. I don't know if SetParent will truly work in this context, it's altogether possible that the FS environment isn't going to respond to SetParent because it may be managing the window itself using some kind of internal nonstandard mechanism. I'm definitely going to first try a timer that delays the call to SetParent for a while, just to see if the concept works, and then later figure out how to determine when it's appropriate to attempt the undock.

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  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...