WM6.5改变了一部分控件的风格,但有些风格在.NET CF中没有相应的改变,例如TabControl控件。这需要通过调用API手动修改。当然这种修改方法并非官方的,只能算作一种hack,所以可能随时失效。
源码:
// In The Hand - .NET Components for Mobility // // InTheHand.WindowsMobile.Forms.TabControlHelper // // Copyright (c) 2009 In The Hand Ltd, All rights reserved. using System; using System.Runtime.InteropServices; using System.Windows.Forms; namespace InTheHand.WindowsMobile.Forms { /// /// Provides helper methods for the on Windows Mobile 6.5. /// public static class TabControlHelper { [DllImport("coredll")] private static extern int GetWindowLong(IntPtr hwnd, int nIndex); private const int GWL_STYLE = -16; [DllImport("coredll")] private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); [DllImport("coredll")] internal static extern IntPtr GetWindow(IntPtr hWnd, int uCmd); private const int GW_CHILD = 5; private const int TCS_TOOLTIPS = 0x4000; /// /// Updates the selected with the Windows Mobile 6.5 style. /// /// public static void EnableVisualStyle(TabControl tabControl) { //get handle of native control IntPtr hNativeTab = GetWindow(tabControl.Handle, GW_CHILD); //get current style flags int style = GetWindowLong(hNativeTab, GWL_STYLE); //add tooltips style style = SetWindowLong(hNativeTab, GWL_STYLE, style | 0x4000); } } } |
详细内容参见Peter Foot的博客:
http://mobileworld.appamundi.com/blogs/peterfoot/archive/2009/09/17/windows-mobile-6-5-tab-control.aspx