Link to home
Start Free TrialLog in
Avatar of cramer091498
cramer091498

asked on

right-to-left style in a CEdit box

I have created a CEdit box with no special styles applied. Its in a dialog.
I then, using SubclassDlgItem, case the CEdit into a CMyEdit.
I want to then change the CEdit so it uses the style WS_EX_RIGHT.
But when I apply the style (using ModifyStyleEx) I cannot see any change.
How do I change this style?

thanks
cel
Avatar of Zoppo
Zoppo
Flag of Germany image

Hi cramer,

first I need to say that WS_EX_RIGHT 'style has an effect only if the shell language is Hebrew, Arabic, or
another language that supports reading-order alignment; otherwise, the style is ignored.' (quote from
MSDN). I hope you know this.

Further, maybe (and I can't test coz I don't have environment where this style has an effect) the
problem is that in windows some styles only affect the creation of a control but don't have any
effect when changed after the object has been created (i.e. ES_MULTILINE). So, you can try
to create the edit-control at runtime using CWnd::CreateEx, i.e.:

CEdit* pEdit = new CEdit;
// even add WS_EX_CLIENTEDGE to give the edit-control the 3D-look
pEdit->CreateEx( WS_EX_CLIENTEDGE|WS_EX_RIGHT, "EDIT", NULL, WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER, CRect(100,100,200,125),
this, 1001);
// BTW, to set the edit control's font to the same as used in the dialog do this:
pEdit->SetFont( GetFont() );

hope that helps,

ZOPPO
Avatar of ekc
ekc

What are you passing as the third parameter of the ModifyStyleEx() function.
If you are not passing nothing, the default is 0. Try with
SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE
Avatar of cramer091498

ASKER

thanks for the comments.
Yes, I can create the CEdit using CreateEx and the style works ok. But I don't want to. I have an application with loads of dialog boxes in resource files and I can't change that.
WS_EX_RIGHT works with any font as far as I can see. It just right justifies text in the CEdit box.

Trying SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE makes no difference.

The first thing I did was read the online help. And I am aware that WS_EX_RIGHT may not be settable at runtime. But I don't know.
Thats why I'm here.

cel
You can simply check the 'Right aligned text' check box in edit-control's
property-tab 'Extended styles'?
thanks for that.
But thats not want I want to do. If I could get away with that I would.
My application creates a dialog box.
If then works out if the customer is Hebrew or English. If Hebrew, I want to dynamically change the CEdit.
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks zoppo.
I'll give that a try

cel
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: Zoppo

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer