50% OFF!!!

Showing posts with label language. Show all posts
Showing posts with label language. Show all posts

Tuesday, August 19, 2008

Making control RTL or LTR

As many people asked me for making rtl or ltr controls on the compactframework.
My best solution for this question is:

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);





CE OS supported:

I tried on "Windows Mobile 6 Classic" emulator and it worked. (CE OS = 5.2)

On "Windows Mobile 5.0 Pocket PC" emulator, also worked. (CE OS = 5.1)


On "Pocket PC 2003 SE" emulator, it did NOT worked! (CE OS = 4.21)


Free Image Hosting at www.ImageShack.us

Download sample test





I hope it will be helpful for you... :)