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.

C Gauge Right Justify String...

Featured Replies

  • Moderator

Dai mentions in the latest tutorial (book?) that there is no way to "...start from the right margin..."Well, the DT_RIGHT flag does work just fine!

MAKE_STRING(ST360_String10,NULL,NULL,IMAGE_USE_ERASE | IMAGE_USE_TRANSPARENCY | BIT7,0,226,40,60,52,3,			MODULE_VAR_NONE,MODULE_VAR_NONE,MODULE_VAR_NONE,RGB(20,20,20),RGB(0,0,0),RGB(0,0,0),			GAUGE_FONT_DEFAULT,GAUGE_WEIGHT_DEFAULT,GAUGE_CHARSET,0,			DT_RIGHT,NULL,			ST360_callback10)PELEMENT_HEADER ST360_ElementList1[] = {&ST360_String10.header,NULL};

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
WinUser.h by the look of it. An update will follow at some point.-Dai
It is defined in winuser.h. Presumably all the other format flags defined in DrawText() should also work?http://msdn.microsoft.com/en-us/library/dd162498(VS.85).aspxEDITMaybe not! According to the FSX and ESP SDKs there are three valid entries for the DRAW_TEXT_FLAGS variable:DT_CENTERDT_VCENTERDT_SINGLELINE

Gerry Howard

  • Author
  • Moderator
:( -Dai
As it turns out, I don't need to right justify the text for this specific string, but since it did work as shown above I thought I'd pass it along... :( What I do need to accomplish is to force my font to be fixed-width, since it is a slighty-slanted digital bold italic font, simulating the old-fashioned segmented displays, which certainly don't wander around the screen... :(

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Commercial Member
Maybe not! According to the FSX and ESP SDKs there are three valid entries for the DRAW_TEXT_FLAGS variable:DT_CENTERDT_VCENTERDT_SINGLELINE
Over the years I've learned not to trust the SDK from (sometimes) painful experience. As Bill has found, DT_CENTER does work, which is why I'd rather test the others before writing them off.-Dai
Over the years I've learned not to trust the SDK from (sometimes) painful experience. As Bill has found, DT_CENTER does work, which is why I'd rather test the others before writing them off.-Dai
That may well be true, but some people have had a different painful experience by discovering and using undocumented system features only to find that they no longer worked following a system update. If a feature's not documented you can't complain if it stops working at some future time.

Gerry Howard

  • Author
  • Moderator
Over the years I've learned not to trust the SDK from (sometimes) painful experience. As Bill has found, DT_CENTER does work, which is why I'd rather test the others before writing them off.-Dai
Actually, it was DT_RIGHT that I found out works just fine, as well as the other "official three."

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • 1 month later...
  • Commercial Member

Update (or necropost, depending on your POV).DT_RIGHT works fine until you combine it with DT_SINGLELINE, at which point it gets ignored. DT_RIGHT also draws the font as proportional. If you want a monospaced, right-biased string you're going to have to figure out a way of padding from the left. Here's a clue: you can create a function that does just that in two lines in C! :( -Dai

  • Commercial Member

I relent.... the work is done in two lines but the check parts take up a bit more. In theory you can calculate the length of the existing string from the strdata parameter but I've found that it's not reliable, hence why I'm passing in the length of the string that needs padding (strlength).

//**************************************************************************//Right-align monospace string (DT_SINGLELINE)// displaysize = length of the display string (MAKE_STRING)// strlength = length of the string to be padded// strdata = string to be right-aligned//**************************************************************************void rightAlign(int displaysize,int strlength,char strdata[256]){	int i=0,j=0;	char newData[256]="";	i=displaysize-strlength;		//Number of blank spaces in the string	if(i>0)	{		for(j=displaysize;j>=0;j--)newData[j]=strdata[j-i];		for(j=0;j<i;j++)newData[j]=' ';		strdata[0]=0;		strncpy(strdata,newData,displaysize);	}	return;}

-Dai

  • Author
  • Moderator

Thanks for the update, Dai. I'm glad you have more time to spare finding such solutions, as I certainly don't have time... :)

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.