# Set edit control text to center

## Recommended Posts

Fish Fishes    100
I have addet edit control in templates. Now I want to change its window text position: I'm using SetWindowLong and setting styles to ES_CENTER. After that I use:
SetWindowPos(hwnd, 0,0,0,0,0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
style is changed but nothing else happens.

##### Share on other sites
ApochPiQ    23058
ES_CENTER cannot be set or modified after the edit control is created; see MSDN for details.

What tool are you using to create the dialog template? It should have an option for adding ES_CENTER at design time.

##### Share on other sites
Aprosenf    372
You could create two edit controls, one centered, one not, and then whenever you want to switch the alignment, you hide one, show the other, and copy the text from the old to the new.