October 20, 200916 yr Commercial Member Anyone have any insight into this issue?// Display Strings //stringFormat.SetAlignment(StringAlignmentCenter); // choose the string alignment: Left, Right, or Centergraphics.DrawString(L"PRE FLIGHT",-1,Arial18,MPRect,&stringFormat,whiteBrush);In FSX, that code will result in the text being centered, which is what I want.But the exact same code in FS9 will result in the GDI text aligning full left. StringAlignmentCenter has no effect in FS9.Any ideas on why this happens in FS9 only?Cheers, B. York FS2Crew Web Site / FS2Crew Facebook Page / FS2Crew Discord
October 20, 200916 yr Commercial Member Since it's strictly a function of GDI+ and not FS... I doubt it has anything to do with FS9 vs FSX.I realize that's not a fix... but, don't want you chasing red herrings. :( Ed Wilson Mindstar AviationMy Playland - I69
October 20, 200916 yr Author Commercial Member Since it's strictly a function of GDI+ and not FS... I doubt it has anything to do with FS9 vs FSX.I realize that's not a fix... but, don't want you chasing red herrings. :(Hi Ed,I know what you're saying, but I'm running the exact same gauge code in FS9 and FSX. It's the same gauge.That's what makes it weird :( Cheers, B. York FS2Crew Web Site / FS2Crew Facebook Page / FS2Crew Discord
October 20, 200916 yr Anyone have any insight into this issue?// Display Strings //stringFormat.SetAlignment(StringAlignmentCenter); // choose the string alignment: Left, Right, or Centergraphics.DrawString(L"PRE FLIGHT",-1,Arial18,MPRect,&stringFormat,whiteBrush);In FSX, that code will result in the text being centered, which is what I want.But the exact same code in FS9 will result in the GDI text aligning full left. StringAlignmentCenter has no effect in FS9.Any ideas on why this happens in FS9 only?Cheers,Two comments that may not help.The second argument, -1, to DrawString() should be the length of the string unless the first argument is a null-terminated string. Is it? The fourth argument, MPRect, should be a PointF. Is it? Gerry Howard
October 20, 200916 yr Commercial Member By default, in C++, L"PRE FLIGHT" is compiled as a null-terminated string.You can pass a RectF pointer instead of a PointF if you want your formatting to be based on a given bounding rectangular area.Since I use StringAlignCenter extensively in FS9 and FSX, I can state categorically it works exactly as expected in both. Ed Wilson Mindstar AviationMy Playland - I69
October 20, 200916 yr By default, in C++, L"PRE FLIGHT" is compiled as a null-terminated string.You can pass a RectF pointer instead of a PointF if you want your formatting to be based on a given bounding rectangular area.Since I use StringAlignCenter extensively in FS9 and FSX, I can state categorically it works exactly as expected in both.Tou are correct. I had missed that there are two overloaded versions of Drawstring():Graphics::DrawString(WCHAR*,INT,Font*,RectF&,StringFormat*,Brush*)andGraphics::DrawString(WCHAR*,INT,Font*,PointF&,Brush*) Gerry Howard
October 23, 200916 yr Author Commercial Member As an update, I fixed this.If it happens to you, make sure you're shutting down the GDI stuff in Case Panel Service Disconnect in only one sub-gauge in a single multi-gauge (I'd suggest using the gauge that loads first).Still weird how it only affected FS9 though...And even weirder why Panel Service Disconnect was being run in the first place when the gauge loaded... B. York FS2Crew Web Site / FS2Crew Facebook Page / FS2Crew Discord
October 23, 200916 yr Commercial Member The service ID calls are different between FS9 and FSX. Ed Wilson Mindstar AviationMy Playland - I69
October 23, 200916 yr Moderator As an update, I fixed this.If it happens to you, make sure you're shutting down the GDI stuff in Case Panel Service Disconnect in only one sub-gauge in a single multi-gauge (I'd suggest using the gauge that loads first).I'm happy to hear you've found a workaround.If you look closely at the first sample I sent you more closely, you'll notice that there is a flag variable that would prevent the GDI shutdown from being run more than once. The idea being that this way you don't have to be concerned about which sub-gauge loads first, nor which one shuts down first... ;) case PANEL_SERVICE_CONNECT_TO_WINDOW: gdiPlusUsers++; if(!init_gdiPlus) { GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); init_gdiPlus = true; } break; case PANEL_SERVICE_DISCONNECT: gdiPlusUsers--; if (init_gdiPlus && gdiPlusUsers == 0) { GdiplusShutdown(gdiplusToken); init_gdiPlus = false; } break; Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
Create an account or sign in to comment