让.NET CF的TabControl控件支持WM6.5风格

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值