Link to home
Start Free TrialLog in
Avatar of Maged-Obied
Maged-Obied

asked on

Right to left controls in Windows mobile

Hi,

i need a way to display controls from right to left on windows mobile applications, my search result was nothing but the mirrored controls, and i couldn't have it running.

if any one has done this before, please help me.

Thanks in advance.
Avatar of hjgode
hjgode
Flag of Germany image

Are you talkingabout controls with text running from right to left?

Or do you search a layout manager that runs on Compact Framework positioning controls automatically from right to left?
 
~Josef
Avatar of Maged-Obied
Maged-Obied

ASKER

what i need is to display the control and the text from right to left, for example a list box showing the text starting from the right and the scroll bar shows on the left side of the list box.
this feature is available in .net with a property for the control, but not in .net CF.
Hi Josef,

sorry i was late in response to you first time i believe this is because the time difference i am +3 UTC.


I tried very hardly and applied this code to the listbox control, but the problem is that the scroll bar is not showing, its looks like it disappear and the layout preserving space for it. see the screenshot.

While i am searching again today i found this article
 http://www.danielmoth.com/Blog/rtl-problem.aspx

he is talking about that windows mobile 5.0 is not supporting the RTL controls.

please tell me if this is correct or what? OR if you have any solution for my problem?

Thanks & Regards
User generated image
#region ##Control Dir change##
        public const int GWL_EXSTYLE = (-20);
        public const int WS_EX_LAYOUTRTL = 0x400000;
        public static void SetControlDirection(Control c, bool p_isRTL)
        {
            int style = GetWindowLong(c.Handle, GWL_EXSTYLE);

            // set default to ltr (clear rtl bit) 
            style &= ~WS_EX_LAYOUTRTL;

            if (p_isRTL == true)
            {
                // rtl 
                style = WS_EX_LAYOUTRTL;
            }

            SetWindowLong(c.Handle, GWL_EXSTYLE, style);
            c.Invalidate();
           
        }


        [DllImport("coredll.dll")]
        static extern int GetWindowLong(IntPtr hWnd, int cmd);

        [DllImport("coredll.dll")]
        static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
        #endregion

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of alexey_gusev
alexey_gusev
Flag of United Kingdom of Great Britain and Northern Ireland 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
Hi alexey,

My device is equipped with a third party Arabization software, otherwise the Arabic text will not show in the listbox, as you can see in the attached picture in my last comment.

this software does not support the RTL for the interface its only supporting displaying the Arabic text.

if you know any software that supports the RTL for the forms and controls please send me its link.

If you know a way that i can make the listbox shows the text from right to left and the scroll bar still on the right please help me with that also, what is the methods i can override to do so.

 
ok, as far as I understand it, the following links should help you:

http://msdn.microsoft.com/en-us/library/ms229679(v=vs.80).aspx
http://www.opennetcf.com/Default.aspx?tabid=120
http://www.ceveni.com/2009/11/owner-drawn-listviews-or-custom-list.html

the idea is to override drawing (and perhaps measuring) methods and then draw whatever you like.

btw, that SmoothListbox at CodeProject is very powerful control because it allows you dumping anything into listbox, so if you want to create a very simple custom control that contains just a textbox (where you can apply Arabic package) then you get what you want. No scrollbar though, but it doesn't matter as one can scroll by finger.
Thanks for your comment,

I had a look on the smoothListBox, the issue that preventing me from using this control that i am already using the list box control in a custom dropDownList control with a lot of different functionality. And it will take time to understand this control and try to run it in my application the way i need.

what i am very confused about, that i have the same code for the RTL working on Windows CE device, but when we were asked to upgrade the application to the Windows mobile Device, i faced this problem.

its very wired because it's the same Framework.    
well, the framework is the same but the underlying OS is NOT, because WM is just a subset of wider WinCE, the 'most robust set of API' as Microsoft put it somewhere. So if something worked on WinCE, it isn't guaranteed to be the same in WM, and vice versa,  take Connection Manager as an example :) So the best solution would be to have the device with localized OS, like for Arabic, Hebrew, Far East languages.

re. SmoothListbox, it's hard to advise you there either in favor or against using it in your project, but from my experience with this control, it's quite like regular listbox, so perhaps it won't be too many changes in your existing code. basically all it does is keeping Items collection where you can add your custom controls and then be notified about the click on particular item.
Thanks for your help,

the conclusion is the Microsoft compact Framework does not support the layout for right to left controls.

does not support means that no guarantee on the way it will look if you applied your own code to do so.

for some controls it will work good, for others will not, and also it depends on the platform.