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.

GDI Text alligns properly in FSX, but not FS9

Featured Replies

  • 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,

  • 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 Aviation
My Playland - I69

  • 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,
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.
  1. The second argument, -1, to DrawString() should be the length of the string unless the first argument is a null-terminated string. Is it?
  2. The fourth argument, MPRect, should be a PointF. Is it?

Gerry Howard

  • 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 Aviation
My Playland - I69

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

  • 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...

  • 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

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.