bcs112 Posted July 31, 2009 Report Posted July 31, 2009 Hi Pete, I've been using offset 3F02 for a while for loading flight data settings in FSX, and it works fine: the counter increases each time a flight is loaded.... but the counter also increases the first FSX switches from windowed mode to full screen mode, giving very undesireable results off course. Is there any way to differentiate FSX actually loading a flight vs a change in window state ? Thanks, Björn
Pete Dowson Posted July 31, 2009 Report Posted July 31, 2009 I've been using offset 3F02 for a while for loading flight data settings in FSX, and it works fine: the counter increases each time a flight is loaded.... but the counter also increases the first FSX switches from windowed mode to full screen mode, giving very undesireable results off course. Really? How strange! I never thought there was any way to tell whether FS was in window or full screen modes. FSUIPC is only detecting flight loading by receiving the "FlightLoaded" event from SimConnect. If SimConnect is sending one of these events when the screen mode changes there must be a bug in SimConnect -- though I find it amazing that anything in Simconnect is anywhere near awarre of such video-side changes. I'll just go and try this now ... ... No, sorry. It certainly doesn't happen here. The count stayed resolutely at 1 even after changing to full screen and back to Windowed. It only increased when I loaded a flight. This is with SP2/Acceleration SimConnect and FSUIPC4 version 4.523 (as in the "Updates" announcement above). Check the logs. Whenever 3F02 is updated, simultaneously the FLT details are logged, like this: 332828 \\LEFT\FSPLANS\Baron at EGCC.FLT 334110 Aircraft="Beech Baron 58 Paint1" The FLT pathname is provided in the data accompanying the "FlightLoaded" system event. Regards Pete
bcs112 Posted August 2, 2009 Author Report Posted August 2, 2009 Hi Pete, Very strange indeed ! I will do some more tests later today, my results are confirmed everytime I test, so ghere must be something else going on ! Björn
bcs112 Posted August 2, 2009 Author Report Posted August 2, 2009 Hi Pete, I checked again and indeed with my panel the counter goes up 1 when I switch from windowed to full screen mode the first time, but this doesn't happen when I use a default FSX aircraft. So the problem must somehow be related to my code. Although I have no idea how I could make this happen myself !!!! Kind regards, Björn
Pete Dowson Posted August 2, 2009 Report Posted August 2, 2009 I checked again and indeed with my panel the counter goes up 1 when I switch from windowed to full screen mode the first time, but this doesn't happen when I use a default FSX aircraft. So the problem must somehow be related to my code. Although I have no idea how I could make this happen myself !!!! Curiouser and curiouser! Tell me, do you get the FLT logged by FSUIPC4 when this happens, because I cannot see how I can increment 3F02 yet bypass the flight logging. And the Flight logging only happens when I receive a "FlightLoaded" event from SimConnect, as that is where I get the flight pathname. It would be interesting to note if this is indeed the name of the last flight loaded. If so, I am wondering whether, somehow, the graphics involved in your panels, or possibly the plane modelling itself, are causing an auto flight reload, as you get after a plane crash (the same as CTRL+; I think). However, I would have thought that, if it were a genuine flight re-load you'd notice the time taken to replenish the scenery and the AI? Perhaps you should select a place with dense scenery and lots of AI, save a flight there, then change screen modes, just to see if you then notice it? Regards Pete
bcs112 Posted August 3, 2009 Author Report Posted August 3, 2009 Hi Pete, Must be something I'm doing that's for sure... Here's some more things I found, probably not related but maybe they ring a bell with you... - When FSX starts and the panel is loaded In the FS "PANEL_SERVICE_PRE_UPDATE:" I check the connection: if (FSUIPC_CONNECTION != FSUIPC_ERR_OK){ FSUIPC_Open2(SIM_ANY, &dwResult, &FsuipcMem[0], 5120); FSUIPC_Write(0x8001, 32, ®, &dwResult); FSUIPC_Process(&dwResult); FSUIPC_CONNECTION = dwResult ; } With: DWORD FSUIPC_CONNECTION=FSUIPC_ERR_NOFS; DWORD dwResult; BYTE FsuipcMem[5120]; dwResult is "0" after the connection is established which is fine off course. - Every time the FSX window is resized or switches from Windowed to Full screen mode and back dwResult is set to "9" and I have to reconnect. Do you happen to see anything irregular ? Björn
Pete Dowson Posted August 3, 2009 Report Posted August 3, 2009 - When FSX starts and the panel is loaded In the FS "PANEL_SERVICE_PRE_UPDATE:" I check the connection: ... I'm not a gauge programmer. Is that called only once per flight/aircraft load? Every time the FSX window is resized or switches from Windowed to Full screen mode and back dwResult is set to "9" and I have to reconnect. I assume you mean dwResult is set to 9 somewhere else, not in the code fragment you showed, as I presume that is the reconnection sequence? Did you check the FSUIPC log? Does it indicate a FlightLoaded event occurring? If your aircraft is being reloaded then that "FsuipcMem" area may be relocated elsewhere. Or possibly your PC is short of memory and when you change modes parts of FS are being thrown out and reloaded afterwards. Shouldn't the memory area be one you allocate on the heap instead of reserving inside your gauge? Of course you have to free it when your gauge is removed, too -- isn't there are call for tidying up before exit? Do you happen to see anything irregular ? Well, apart from the possibility of the shared memory address changing, and not knowing what "PANEL_SERVICE_PRE_UPDATE" is, no. Regards Pete
bcs112 Posted August 4, 2009 Author Report Posted August 4, 2009 I can't seem to find anything wrong in my code, but I found found code snippets that tells you the current window state of the FSX window. There are two procedures: WINDOWPLACEMENT wd; UINT nCurShow; HWND hWnd = FindWindow("FS98MAIN",NULL); if (GetWindowPlacement( hWnd, &wd )){ nCurShow = wd.showCmd; } Will return the current window state but can not differentiate between full screen and windowed modes. bool IsFullScreenMode(){ int w = GetSystemMetrics(SM_CXSCREEN); int h = GetSystemMetrics(SM_CYSCREEN); HWND hWnd = 0; while (hWnd = FindWindowEx(NULL, hWnd, NULL, NULL)) { if (GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) { RECT rcWindow; GetWindowRect(hWnd, &rcWindow); if ((w == (rcWindow.right - rcWindow.left)) && (h == (rcWindow.bottom - rcWindow.top))) return true; } } return false; } Returns wether FSX is in full screen versus windowed mode. I tried it and it works fine ! Björn
Pete Dowson Posted August 4, 2009 Report Posted August 4, 2009 I can't seem to find anything wrong in my code, but I found found code snippets that tells you the current window state of the FSX window. Oh, well done. Maybe I should provide this info in offsets. Could be useful. Oh, one little possible niggle. Because this is based merely on checking the Window size against the screen size, what happens if I make my FS window size slightly bigger than the screen size and positioned so that the title bar is off screen at the top? I used to do this sort of thing to get rid of the title bar view yet still have Windowed mode and so access to other programs. Maybe we can also check whether the title bar actually exists, just to eliminate this possibility. Regards, Pete
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now