您的位置:首页 > 其它

为.NET CF 中的TabControl控件添加WM6.5效果

2010-03-08 15:39 411 查看
WM6.5中的TabControl拥有了全新的界面,但是在.NET CF中的控件仍然是老面孔,很不好看。在这里贴一个老外的解决方法,很简洁:

// 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);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: