• 群里人问的消息切换分页问题,我就标记一下


    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();
            }
        }
    }
    

     如题,获取到tabcontrol控件句柄后使用
    SendMessage(hTab,TCM_SETCURFOCUS,1,0);//这句话是相当重要的,不然的话tab子窗口不会跟随切换。就这一句话,搞了很久。
    SendMessage(hTab,TCM_SETCURSEL,2,0);//想切换的的tab控件的第二个索引项
    验证无效,烦请各位大大帮看下问题出在哪里?

  • 相关阅读:
    GB/T 38635.1-2020 信息安全技术 SM9标识密码算法 第1部分:总则
    信息安全行业国家标准汇总,信息安全行业从业人员必看
    贪吃蛇游戏(printf输出C语言版本)
    C 实战练习题目57
    C 实战练习题目56
    C 实战练习题目55
    C 实战练习题目54
    C 实战练习题目53
    C 实战练习题目52
    C 实战练习题目51
  • 原文地址:https://www.cnblogs.com/ZhouXiHong/p/4432617.html
Copyright © 2020-2023  润新知