February 8, 201016 yr 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
February 8, 201016 yr Commercial Member That requires knowledge of which header declares DT_RIGHT to be useable. Ed Wilson Mindstar AviationMy Playland - I69
February 9, 201016 yr Commercial Member WinUser.h by the look of it. An update will follow at some point.-Dai
February 9, 201016 yr WinUser.h by the look of it. An update will follow at some point.-DaiIt 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
February 9, 201016 yr Author Moderator :( -DaiAs 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
February 9, 201016 yr Commercial Member Contact me Bill. Ed Wilson Mindstar AviationMy Playland - I69
February 9, 201016 yr 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_SINGLELINEOver 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
February 9, 201016 yr 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.-DaiThat 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
February 10, 201016 yr 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.-DaiActually, 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
March 18, 201016 yr 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
March 19, 201016 yr 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
March 19, 201016 yr 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