예제 #1
0
        public void Select(string value)
        {
            Log.INFO(string.Format("Select TabCtrl:[{0}] value:[{1}]", _Text, value));

            //Console.WriteLine(string.Format("{0} {1}", hWnd.ToString("x8"), winClass));

            int index  = -1;
            int rowNum = WinAPI.GetTabCtrlItemNum(_hWnd);

            for (int i = 0; i < rowNum; i++)
            {
                string strText = WinAPI.GetTabCtrlItemText(_hWnd, i);
                if (strText == value)
                {
                    index = i;
                    break;
                }
            }

            if (index == -1)
            {
                throw new Exception(string.Format("Can not find value[{0}] in TabCtrl:[{1}]", value, _Text));
            }

            WinAPI.SendMessage(_hWnd, (int)WinAPI.TabCtrlMessage.TCM_SETCURFOCUS, (IntPtr)(index), IntPtr.Zero);
            WinAPI.SendMessage(_hWnd, (int)WinAPI.TabCtrlMessage.TCM_SETCURSEL, (IntPtr)(index), IntPtr.Zero);
        }