Solved

Unicode Font in C# for Windows Mobile Programming

Posted on 2007-11-20
5
2,941 Views
Last Modified: 2013-12-21
hi
i am a beginner programmer in windows mobile but a professional programmer in other os.
i know C# average and i am a new programmer for pocket pc.
i want show my labels in persian language or arabic in unicode format.when i write a strind in Visual studio 2005 (C#),that's correct but when i run program pocket pc simulator doesn't show that correct in unicode format,this is first my problem.
but when run this program on pocket pc,pocket pc show my persian string in reverse format,my text show from end to first ,this is more important for me.
what is solution? please hel me step by step for showing my text in correct unicode format.
thanks
0
Comment
Question by:mr_mpz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 3

Accepted Solution

by:
wizrr earned 200 total points
ID: 20326921
Hi.
You need to implement RTL (right to left) reading in your text box\label? Try apply WS_EX_RTLREADING style to your control (i never used that, but should work). You can download OpenNetCF open source library to get experience with windows native. There are a lot of code like code i provide for you:
// as that style exists in winuser.h we define following:
// #define WS_EX_RTLREADING        0x00002000L
readonly int WS_EX_RTLREADING = unchecked(0x00002000L);
 
public enum GetWindowLongType : int {
  EXSTYLE = -20,
  HINSTANCE = -6,
  HWNDPARENT = -8,
  ID = -12,
  STYLE = -16,
  USERDATA = -21,
  WNDPROC = -4
}
 
[Flags]
public enum SetWindowPositionFlags {
	ASYNCWINDOWPOS = 0x4000,
	DEFERERASE = 0x2000,
	DRAWFRAME = 0x20,
	FRAMECHANGED = 0x20,
	HIDEWINDOW = 0x80,
	NOACTIVATE = 0x10,
	NOCOPYBITS = 0x100,
	NOMOVE = 2,
	NOOWNERZORDER = 0x200,
	NOREDRAW = 8,
	NOREPOSITION = 0x200,
	NOSENDCHANGING = 0x400,
	NOSIZE = 1,
	NOZORDER = 4,
	SHOWWINDOW = 0x40
}
 
[DllImport("coredll.dll", SetLastError=true)]
public static extern int GetWindowLong(IntPtr hWnd, GetWindowLongType gwlType);
 
[DllImport("coredll.dll", SetLastError=true)]
public static extern void SetWindowLong(IntPtr hWnd, 
    GetWindowLongType gwlType, int nValue);
 
 
[DllImport("coredll.dll", SetLastError=true)]
public static extern int SetWindowPos(IntPtr hWnd, HWND pos, 
    int X, int Y, int cx, int cy, SetWindowPositionFlags uFlags);
 
public bool RightToLeftReading {
  get {
    if ((GetWindowLong(this.Handle, GetWindowLongType.EXSTYLE) & WS_EX_RTLREADING)
        == WS_EX_RTLREADING) {
      // WS_EX_RTLREADING flag exists
      return ( true );
    } else {
      // WS_EX_RTLREADING flag does not exists
      return ( false );
    }
  }
  set {
    if (RightToLeftReading != value)
    if ( value ) {
      int longFlags = GetWindowLong(this.Handle, GetWindowLongType.EXSTYLE);
      SetWindowLong(this.Handle, GetWindowLongType.EXSTYLE, longFlags | WS_EX_RTLREADING);
      SetWindowLong(this.Handle, GetWindowLongType.EXSTYLE, longFlags | WS_EX_RTLREADING);
      // update control
      SetWindowPos(hwnd, HWND.TOPMOST, 0, 0, 0, 0, 
         SetWindowPositionFlags.DRAWFRAME | 
         SetWindowPositionFlags.NOACTIVATE | 
         SetWindowPositionFlags.NOMOVE | 
         SetWindowPositionFlags.NOSIZE);
    } else {
      int longFlags = GetWindowLong(this.Handle, GetWindowLongType.EXSTYLE);
      // try set two times because of SetWindowLong CE bugs
      SetWindowLong(this.Handle, GetWindowLongType.EXSTYLE, longFlags & ~WS_EX_RTLREADING);
      SetWindowLong(this.Handle, GetWindowLongType.EXSTYLE, longFlags & ~WS_EX_RTLREADING);
      // update control
      SetWindowPos(hwnd, HWND.TOPMOST, 0, 0, 0, 0, 
         SetWindowPositionFlags.DRAWFRAME | 
         SetWindowPositionFlags.NOACTIVATE | 
         SetWindowPositionFlags.NOMOVE | 
         SetWindowPositionFlags.NOSIZE);
    }
  }
}

Open in new window

0
 
LVL 3

Expert Comment

by:wizrr
ID: 20326943
Oh, if that works don't forget to check is control created in design time or not. Because in design time we can't access native functions from coredll.dll. You should do something like this:

if ( Site == null || (Site != null && !Site.IsDesignTime) || !IsDesignTime()) {
  // call native methods
} else {
  // try to implement native methods by yourself (or use same native methods but from normal Windows not CE)
}
...
public static bool IsDesignTime()
{
        Assembly assembly = typeof(int).Assembly;
        return ((assembly != null) && assembly.FullName.ToUpper().EndsWith("B77A5C561934E089"));
}

Open in new window

0
 
LVL 1

Author Comment

by:mr_mpz
ID: 20331976
thanks,let i test that
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20633082
Forced accept.

Computer101
EE Admin
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
File Foler Permission 4 32
Windows Server 2012 Start Menu 6 49
Problem to setting 16 46
Windows 7 - How to Extend Hard Drive Boot Partition 12 58
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question