Exemplo n.º 1
0
        // Retrieve the text of the list portion of Combo.
        // Or Text of the edit portion of ComboBoxEx32 (path -1 as index)
        // Use CB_XXX instead of LB_XXX, since CB_XXX will give us back text in ownerdrawn combo
        static private string SpecialText(IntPtr hwnd, int index)
        {
            if (index == -1)
            {
                // get the selected element
                index = Misc.ProxySendMessageInt(hwnd, NativeMethods.CB_GETCURSEL, IntPtr.Zero, IntPtr.Zero);
                if (index == -1)
                {
                    return("");
                }
            }

            int len = Misc.ProxySendMessageInt(hwnd, NativeMethods.CB_GETLBTEXTLEN, new IntPtr(index), IntPtr.Zero);

            if (len < 1)
            {
                return("");
            }

            if (Misc.GetClassName(hwnd).Equals("Internet Explorer_TridentCmboBx"))
            {
                // The Trident listbox is a superclassed standard listbox.
                // Trident listboxes are owner draw that does not have the hasstring style set.
                // All the control contains is the owner draw data and not text.  Private
                // messages were added to retrieve the owner draw data as text.  The new messages
                // are used just like the normally LB_GETTEXT and CB_GETTEXT messages.
                return(XSendMessage.GetItemText(hwnd, NativeMethods.WM_USER + NativeMethods.CB_GETLBTEXT, index, len));
            }
            else
            {
                return(Misc.GetUnsafeText(hwnd, NativeMethods.CB_GETLBTEXT, new IntPtr(index), len));
            }
        }
        private static string GetItemText(IntPtr hwnd, int itemIndex)
        {
            NativeMethods.TCITEM tcitem = new NativeMethods.TCITEM();
            tcitem.Init();

            tcitem.mask       = NativeMethods.TCIF_TEXT;
            tcitem.cchTextMax = Misc.MaxLengthNameProperty;

            return(XSendMessage.GetItemText(hwnd, itemIndex, tcitem));
        }