110,538
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
namespace Text
{
public class Program
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern UInt32 SendMessage(IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam);
public const UInt32 TCM_FIRST = 0x1300;
public const UInt32 TCM_GETIMAGELIST = (TCM_FIRST + 2);
public const UInt32 TCM_SETIMAGELIST = (TCM_FIRST + 3);
public const UInt32 TCM_GETITEMCOUNT = (TCM_FIRST + 4);
public const UInt32 TCM_GETITEMA = (TCM_FIRST + 5);
public const UInt32 TCM_GETITEMW = (TCM_FIRST + 60);
public const UInt32 TCM_SETITEMA = (TCM_FIRST + 6);
public const UInt32 TCM_SETITEMW = (TCM_FIRST + 61);
public const UInt32 TCM_INSERTITEMA = (TCM_FIRST + 7);
public const UInt32 TCM_INSERTITEMW = (TCM_FIRST + 62);
public const UInt32 TCM_DELETEITEM = (TCM_FIRST + 8);
public const UInt32 TCM_DELETEALLITEMS = (TCM_FIRST + 9);
public const UInt32 TCM_GETITEMRECT = (TCM_FIRST + 10);
public const UInt32 TCM_GETCURSEL = (TCM_FIRST + 11);
public const UInt32 TCM_SETCURSEL = (TCM_FIRST + 12);
public const UInt32 TCM_HITTEST = (TCM_FIRST + 13);
public const UInt32 TCM_SETITEMEXTRA = (TCM_FIRST + 14);
public const UInt32 TCM_ADJUSTRECT = (TCM_FIRST + 40);
public const UInt32 TCM_SETITEMSIZE = (TCM_FIRST + 41);
public const UInt32 TCM_REMOVEIMAGE = (TCM_FIRST + 42);
public const UInt32 TCM_SETPADDING = (TCM_FIRST + 43);
public const UInt32 TCM_GETROWCOUNT = (TCM_FIRST + 44);
public const UInt32 TCM_GETCURFOCUS = (TCM_FIRST + 47);
public const UInt32 TCM_SETCURFOCUS = (TCM_FIRST + 48);
public const UInt32 TCM_SETMINTABWIDTH = (TCM_FIRST + 49);
public const UInt32 TCM_DESELECTALL = (TCM_FIRST + 50);
public const UInt32 TCM_HIGHLIGHTITEM = (TCM_FIRST + 51);
public const UInt32 TCM_SETEXTENDEDSTYLE = (TCM_FIRST + 52); // optional wParam == mask
public const UInt32 TCM_GETEXTENDEDSTYLE = (TCM_FIRST + 53);
static void Main(string[] args)
{
IntPtr h = new IntPtr(句柄自己取);
UInt32 count = SendMessage(h, TCM_GETITEMCOUNT, 0, 0);
Console.WriteLine("共有 " + count + " 个分页");
UInt32 index = SendMessage(h, TCM_GETCURSEL, 0, 0);
Console.WriteLine("当前选中第 " + (index + 1) + " 页");
if (index == 0)
{
index = count - 1;
}
else
{
index = 0;
}
SendMessage(h, TCM_SETCURSEL, index, 0);
Console.WriteLine("已跳转到 " + (index + 1) + " 页");
Console.ReadKey();
}
}
}