Claus
asked on
How to dynamically switch reading order in CEdit
I have been struggling to switch reading order in a CEdit, trying for instance:
m_wndCellEdit.ModifyStyleE x(WS_EX_LT RREADING, WS_EX_RTLREADING, 0);
m_wndCellEdit.ModifyStyleE x(WS_EX_LE FT, WS_EX_RIGHT, 0);
m_wndCellEdit.InvalidateRe ct( NULL, false );
and
LONG lAlign = GetWindowLong( m_wndCellEdit.m_hWnd, GWL_EXSTYLE);
lAlign ^= WS_EX_RIGHT;
lAlign ^= WS_EX_RTLREADING;
SetWindowLong( m_wndCellEdit.m_hWnd, GWL_EXSTYLE, lAlign);
m_wndCellEdit.InvalidateRe ct( NULL, false );
But nothing works. The CEdit remains with LTR reading order. I want to be able to switch dynamically between LTR and RTL but it doesn't seem to be possible?
Can anyone help? I urgently need a solution.
Thanks,
Claus
m_wndCellEdit.ModifyStyleE
m_wndCellEdit.ModifyStyleE
m_wndCellEdit.InvalidateRe
and
LONG lAlign = GetWindowLong( m_wndCellEdit.m_hWnd, GWL_EXSTYLE);
lAlign ^= WS_EX_RIGHT;
lAlign ^= WS_EX_RTLREADING;
SetWindowLong( m_wndCellEdit.m_hWnd, GWL_EXSTYLE, lAlign);
m_wndCellEdit.InvalidateRe
But nothing works. The CEdit remains with LTR reading order. I want to be able to switch dynamically between LTR and RTL but it doesn't seem to be possible?
Can anyone help? I urgently need a solution.
Thanks,
Claus
ASKER
How do I send this message to the CEdit? Can you give me an example?
Thanks,
Claus
Thanks,
Claus
You may use m_wndCellEdit.SendMessage( EM_SETPARA FORMAT,... ...
-MAHESH
-MAHESH
You may also refer this thread too : https://www.experts-exchange.com/questions/21796818/CRichEditCtrl-and-switching-between-left-to-right-and-right-to-left-text.html
-MAHESH
-MAHESH
ASKER
But it seems it didn't work in the other thread ...
I'm having trouble using SendMessage ... can you provide an example?
I'm having trouble using SendMessage ... can you provide an example?
ASKER
I did the following but it still doesn't work:
PARAFORMAT2 p;
p.dwMask = PFM_RTLPARA;
p.cbSize = sizeof( PARAFORMAT2 );
m_wndCellEdit.SendMessage( EM_SETPARAFORMAT, 0, (LPARAM)&p );
PARAFORMAT2 p;
p.dwMask = PFM_RTLPARA;
p.cbSize = sizeof( PARAFORMAT2 );
m_wndCellEdit.SendMessage(
PARAFORMAT2 paraFmt;
::ZeroMemory(¶Fmt, sizeof(PARAFORMAT2));
paraFmt.cbSize = sizeof(PARAFORMAT2);
paraFmt.wEffects = PFM_RTLPARA;
.....
m_wndCellEdit.SendMessage( EM_SETPARA FORMAT, 0L, reinterpret_cast<LPARAM>(& paraFmt));
Refer for more above : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditstructures/paraformat2.asp
-MAHESH
::ZeroMemory(¶Fmt, sizeof(PARAFORMAT2));
paraFmt.cbSize = sizeof(PARAFORMAT2);
paraFmt.wEffects = PFM_RTLPARA;
.....
m_wndCellEdit.SendMessage(
Refer for more above : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditstructures/paraformat2.asp
-MAHESH
ASKER
I modified my code to match yours but it still doesn't work.
Also, it didn't seem to work in the other thread ... so are you sure it should work?
Someone in the other thread indicated that possibly these styles can only be modified when the CEdit is created. Could this be true?
Claus
Also, it didn't seem to work in the other thread ... so are you sure it should work?
Someone in the other thread indicated that possibly these styles can only be modified when the CEdit is created. Could this be true?
Claus
>>Someone in the other thread indicated that possibly these styles can only be modified when the CEdit is created. Could this be true?
yeah you may give that try....
used CreateEx rather than Create to create Edit control; not knowing that the CreateEx simply calls ModifyStyleEx AFTER the control is already created...So instead override the PreCreateWindow class and set the style:
BOOL CMyEditCtrl::PreCreateWind ow(CREATES TRUCT& cs)
{
cs.dwExStyle |= WS_EX_RTLREADING;
return CMyEditCtrl::PreCreateWind ow(cs);
}
-MAHESH
yeah you may give that try....
used CreateEx rather than Create to create Edit control; not knowing that the CreateEx simply calls ModifyStyleEx AFTER the control is already created...So instead override the PreCreateWindow class and set the style:
BOOL CMyEditCtrl::PreCreateWind
{
cs.dwExStyle |= WS_EX_RTLREADING;
return CMyEditCtrl::PreCreateWind
}
-MAHESH
ASKER
Unfortunately this is not what I need. I could do this already. I do need the dynamic modification of the control but perhaps it just isn't possible.
Claus
Claus
ASKER
Ok, perhaps I have to accept that I must have a special Arabic version of my software if I cannot switch layout dynamically.
I have made such a version now using all the above tricks. So text is now displayed in the right side of my CEdit's. However, if I use Google translate to get me some Arabic text and copy/paste it into the CEdit, it is reversed.
Why is this?
If you help me resolve this, I will give you the points?
I have made such a version now using all the above tricks. So text is now displayed in the right side of my CEdit's. However, if I use Google translate to get me some Arabic text and copy/paste it into the CEdit, it is reversed.
Why is this?
If you help me resolve this, I will give you the points?
You dont have arabic version of software... SO just copy / paste arabic text in your editbox will not help you to display your text right to left order as your control is not supporting RTL order yet....
I think it seems deriving your own control from CEdit and customizing it is the only solutions for this..
-MAHESH
I think it seems deriving your own control from CEdit and customizing it is the only solutions for this..
-MAHESH
ASKER
If I installed the Arabic version of MS Visual, I could get it?
Or are you saying my application would work correctly on an Arabic version of Windows?
Or are you saying my application would work correctly on an Arabic version of Windows?
Yes I am saying saying my application would work correctly on an Arabic version of Windows.. As doumentation states as said above :
WS_EX_RTLREADING : If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the window text is displayed using Right to Left reading-order properties. For other languages, the style is ignored and not treated as an error
-MAHESH
WS_EX_RTLREADING : If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the window text is displayed using Right to Left reading-order properties. For other languages, the style is ignored and not treated as an error
-MAHESH
ASKER
Isn't there a way I can set my Windows up to this?
Or at least one of the applications? I copied from Internet Explorer, and that was reversed.
Or at least one of the applications? I copied from Internet Explorer, and that was reversed.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, understood ! You get the points.
Do you think it's possible the dynamic behavior would work under Arabic windows?
Thanks,
Claus
Do you think it's possible the dynamic behavior would work under Arabic windows?
Thanks,
Claus
yes it will work thou i have not tried but documentation says so.
-MAHESH
-MAHESH
Try to Use the EM_SETPARAFORMAT message. Set PFE_RTLPARA in the PARAFORMAT2 structure when sending EM_SETPARAFORMAT
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/richedit/richeditcontrols/richeditcontrolreference/richeditstructures/paraformat2.asp
-MAHESH