Click to See Complete Forum and Search --> : WindowsTextBox


Joshua
April 22nd, 1999, 12:41 AM
Well I got my Calculator all running in win-32 format. The only problem I want to fix is how to set the text to be right-justified? It's automatically left-justified. And since this is in C, it's not easily shown. Someone mentioned 'ED_RIGHTJUSTIFY', but we're not sure.
Also at the moment all my numbers are floats. when they are shown it might be like 80.0000 is there a way to truncated the extra zeros, so that each time if there are extra 0's?

eric33
April 22nd, 1999, 01:49 AM
I you are using a studio you have just to change the property

Hovewer the alignment property is one of the styles of a window.
To change it use the next example :

DWORD style;
style = GetWindowLong(hWnd, GWL_STYLE);
style = style | ES_RIGHT ;
SetLastError(0);
SetWindowLong(hWnd, GWL_STYLE, style);

Concerning the lead zeros of your float number I am not sure to understand your problem.
But try to use the sprintf C function to first format your number in a string and then send the string to the text box.

Example :
char string[10];
float number=80f;
sprintf(string,"%0.02f",mynumber);
SetWindowText(textHwnd,string);