protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.ResetAutoComplete(true);
         if (this.autoCompleteCustomSource != null)
         {
             this.autoCompleteCustomSource.CollectionChanged -= new CollectionChangeEventHandler(this.OnAutoCompleteCustomSourceChanged);
         }
         if (this.stringSource != null)
         {
             this.stringSource.ReleaseAutoComplete();
             this.stringSource = null;
         }
     }
     base.Dispose(disposing);
 }
Beispiel #2
0
        private void SetAutoComplete(bool reset, bool recreate) {
            if (!IsHandleCreated || childEdit == null) {
                return;
            }

            if (AutoCompleteMode != AutoCompleteMode.None) {
                if (!fromHandleCreate && recreate && IsHandleCreated)
                {
                    //RecreateHandle to avoid Leak.
                    // notice the use of member variable to avoid re-entrancy
                    AutoCompleteMode backUpMode = this.AutoCompleteMode;
                    autoCompleteMode = AutoCompleteMode.None;
                    RecreateHandle();
                    autoCompleteMode = backUpMode;
                }
                
                if (AutoCompleteSource == AutoCompleteSource.CustomSource) {
                    if (AutoCompleteCustomSource != null) {
                        if (AutoCompleteCustomSource.Count == 0) {
                            int mode = NativeMethods.AUTOSUGGEST_OFF | NativeMethods.AUTOAPPEND_OFF;
                            SafeNativeMethods.SHAutoComplete(new HandleRef(this, childEdit.Handle), mode);
                        }
                        else {

                            if (stringSource == null)
                            {
                                stringSource = new StringSource(GetStringsForAutoComplete(AutoCompleteCustomSource));
                                if (!stringSource.Bind(new HandleRef(this, childEdit.Handle), (int)AutoCompleteMode)) {
                                    throw new ArgumentException(SR.GetString(SR.AutoCompleteFailure));
                                }
                            }
                            else
                            {
                                stringSource.RefreshList(GetStringsForAutoComplete(AutoCompleteCustomSource));
                            }
                            
                        }
                    }
                }
                else if (AutoCompleteSource == AutoCompleteSource.ListItems) {
                    if (DropDownStyle != ComboBoxStyle.DropDownList) {
                        if (itemsCollection != null) {
                            if (itemsCollection.Count == 0) {
                                int mode = NativeMethods.AUTOSUGGEST_OFF | NativeMethods.AUTOAPPEND_OFF;
                                SafeNativeMethods.SHAutoComplete(new HandleRef(this, childEdit.Handle), mode);
                            }
                            else {

                                if (stringSource == null)
                                {
                                    stringSource = new StringSource(GetStringsForAutoComplete(Items));
                                    if (!stringSource.Bind(new HandleRef(this, childEdit.Handle), (int)AutoCompleteMode)) {
                                        throw new ArgumentException(SR.GetString(SR.AutoCompleteFailureListItems));
                                    }
                                }
                                else
                                {
                                    stringSource.RefreshList(GetStringsForAutoComplete(Items));
                                }
                                
                            }
                        }
                    }
                    else {
                        // Drop Down List special handling
                        Debug.Assert(DropDownStyle == ComboBoxStyle.DropDownList);
                        int mode = NativeMethods.AUTOSUGGEST_OFF | NativeMethods.AUTOAPPEND_OFF;
                        SafeNativeMethods.SHAutoComplete(new HandleRef(this, childEdit.Handle), mode);
                    }
                }
                else {
                    try {
                        int mode = 0;

                        if (AutoCompleteMode == AutoCompleteMode.Suggest) {
                            mode |= NativeMethods.AUTOSUGGEST | NativeMethods.AUTOAPPEND_OFF;
                        }
                        if (AutoCompleteMode == AutoCompleteMode.Append) {
                            mode |= NativeMethods.AUTOAPPEND | NativeMethods.AUTOSUGGEST_OFF;
                        }
                        if (AutoCompleteMode == AutoCompleteMode.SuggestAppend) {
                            mode |= NativeMethods.AUTOSUGGEST;
                            mode |= NativeMethods.AUTOAPPEND;
                        }
                        int ret = SafeNativeMethods.SHAutoComplete(new HandleRef(this, childEdit.Handle), (int)AutoCompleteSource | mode);
                    }
                    catch (SecurityException) {
                        // If we don't have full trust, degrade gracefully. Allow the control to
                        // function without auto-complete. Allow the app to continue running.
                    }
                }
            }
            else if (reset) {
                int mode = NativeMethods.AUTOSUGGEST_OFF | NativeMethods.AUTOAPPEND_OFF;
                SafeNativeMethods.SHAutoComplete(new HandleRef(this, childEdit.Handle), mode);
            }
        }
Beispiel #3
0
 /// <include file='doc\ComboBox.uex' path='docs/doc[@for="ComboBox.OnHandleDestroyed"]/*' />
 /// <devdoc>
 ///     We need to un-subclasses everything here.  Inheriting classes should
 ///     not forget to call base.OnHandleDestroyed()
 /// </devdoc>
 /// <internalonly/>
 protected override void OnHandleDestroyed(EventArgs e) {
     dropDownHandle = IntPtr.Zero;
     if (Disposing) {
         itemsCollection = null;
         selectedIndex = -1;
     }
     else {
         selectedIndex = SelectedIndex;
     }
     if (stringSource != null)
     {
         stringSource.ReleaseAutoComplete();
         stringSource = null;
     }
     base.OnHandleDestroyed(e);
 }
 void IEnumString.Clone(out IEnumString ppenum)
 {
     ppenum = new StringSource(this.strings);
 }
Beispiel #5
0
        /// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.SetAutoComplete"]/*' />
        /// <devdoc>
        ///     Sets the AutoComplete mode in TextBox.
        /// </devdoc>
        internal void SetAutoComplete(bool reset)
        {
            //Autocomplete Not Enabled for Password enabled and MultiLine Textboxes.
            if (Multiline || passwordChar != 0 || useSystemPasswordChar || AutoCompleteSource == AutoCompleteSource.None) {
                return;
            }

            if (AutoCompleteMode != AutoCompleteMode.None) {
                if (!fromHandleCreate)
                {
                    //RecreateHandle to avoid Leak.
                    // notice the use of member variable to avoid re-entrancy
                    AutoCompleteMode backUpMode = this.AutoCompleteMode;
                    autoCompleteMode = AutoCompleteMode.None;
                    RecreateHandle();
                    autoCompleteMode = backUpMode;
                }
                
                if (AutoCompleteSource == AutoCompleteSource.CustomSource) {
                    if (IsHandleCreated && AutoCompleteCustomSource != null) {
                        if (AutoCompleteCustomSource.Count == 0) {
                            ResetAutoComplete(true);
                        }
                        else {
                            if (stringSource == null)
                            {
                                stringSource = new StringSource(GetStringsForAutoComplete());
                                if (!stringSource.Bind(new HandleRef(this, Handle), (int)AutoCompleteMode))
                                {
                                   throw new ArgumentException(SR.GetString(SR.AutoCompleteFailure));
                                }
                            }
                            else
                            {
                                stringSource.RefreshList(GetStringsForAutoComplete());
                            }
                        }
                    }
        
                }
                else {
                    try {
                        if (IsHandleCreated) {
                            int mode = 0;
                            if (AutoCompleteMode == AutoCompleteMode.Suggest) {
                                mode |=  NativeMethods.AUTOSUGGEST | NativeMethods.AUTOAPPEND_OFF;
                            }
                            if (AutoCompleteMode == AutoCompleteMode.Append) {
                                mode |=  NativeMethods.AUTOAPPEND | NativeMethods.AUTOSUGGEST_OFF;
                            }
                            if (AutoCompleteMode == AutoCompleteMode.SuggestAppend) {
                                mode |=  NativeMethods.AUTOSUGGEST;
                                mode |=  NativeMethods.AUTOAPPEND;
                            }
                            int ret = SafeNativeMethods.SHAutoComplete(new HandleRef(this, Handle) , (int)AutoCompleteSource | mode);
                        }
                    }
                    catch (SecurityException) {
                        // If we don't have full trust, degrade gracefully. Allow the control to
                        // function without auto-complete. Allow the app to continue running.
                    }
                }
            }
            else if (reset) {
                ResetAutoComplete(true);
            }
        }
Beispiel #6
0
 protected override void OnHandleDestroyed(EventArgs e)
 {
     if (stringSource != null)
     {
         stringSource.ReleaseAutoComplete();
         stringSource = null;
     }
     base.OnHandleDestroyed(e);
 }
Beispiel #7
0
 /// <include file='doc\TabControl.uex' path='docs/doc[@for="TextBox.Dispose"]/*' />
 protected override void Dispose(bool disposing) {
     if (disposing) {
         // VSWhidbey 281668 - Reset this just in case, because the SHAutoComplete stuff
         // will subclass this guys wndproc (and nativewindow can't know about it).
         // so this will undo it, but on a dispose we'll be Destroying the window anyay.
         //
         ResetAutoComplete(true);
         if (autoCompleteCustomSource != null) {
             autoCompleteCustomSource.CollectionChanged -= new CollectionChangeEventHandler(this.OnAutoCompleteCustomSourceChanged);
         }
         if (stringSource != null)
         {
             stringSource.ReleaseAutoComplete();
             stringSource = null;
         }
     }
     base.Dispose(disposing);
 }
 internal void SetAutoComplete(bool reset)
 {
     if (this.Multiline || (int) this.passwordChar != 0 || (this.useSystemPasswordChar || this.AutoCompleteSource == AutoCompleteSource.None))
     return;
       if (this.AutoCompleteMode != AutoCompleteMode.None)
       {
     if (!this.fromHandleCreate)
     {
       AutoCompleteMode autoCompleteMode = this.AutoCompleteMode;
       this.autoCompleteMode = AutoCompleteMode.None;
       this.RecreateHandle();
       this.autoCompleteMode = autoCompleteMode;
     }
     if (this.AutoCompleteSource == AutoCompleteSource.CustomSource)
     {
       if (!this.IsHandleCreated || this.AutoCompleteCustomSource == null)
     return;
       if (this.AutoCompleteCustomSource.Count == 0)
     this.ResetAutoComplete(true);
       else if (this.stringSource == null)
       {
     this.stringSource = new StringSource(this.GetStringsForAutoComplete());
     if (!this.stringSource.Bind(new HandleRef((object) this, this.Handle), (int) this.AutoCompleteMode))
       throw new ArgumentException(System.Windows.Forms.SR.GetString("AutoCompleteFailure"));
       }
       else
     this.stringSource.RefreshList(this.GetStringsForAutoComplete());
     }
     else
     {
       try
       {
     if (!this.IsHandleCreated)
       return;
     int num = 0;
     if (this.AutoCompleteMode == AutoCompleteMode.Suggest)
       num |= -1879048192;
     if (this.AutoCompleteMode == AutoCompleteMode.Append)
       num |= 1610612736;
     if (this.AutoCompleteMode == AutoCompleteMode.SuggestAppend)
       num = num | 268435456 | 1073741824;
     System.Windows.Forms.SafeNativeMethods.SHAutoComplete(new HandleRef((object) this, this.Handle), (int) (this.AutoCompleteSource | (AutoCompleteSource) num));
       }
       catch (SecurityException ex)
       {
       }
     }
       }
       else
       {
     if (!reset)
       return;
     this.ResetAutoComplete(true);
       }
 }
 internal void SetAutoComplete(bool reset)
 {
     if ((!this.Multiline && (this.passwordChar == '\0')) && (!this.useSystemPasswordChar && (this.AutoCompleteSource != System.Windows.Forms.AutoCompleteSource.None)))
     {
         if (this.AutoCompleteMode != System.Windows.Forms.AutoCompleteMode.None)
         {
             if (!this.fromHandleCreate)
             {
                 System.Windows.Forms.AutoCompleteMode autoCompleteMode = this.AutoCompleteMode;
                 this.autoCompleteMode = System.Windows.Forms.AutoCompleteMode.None;
                 base.RecreateHandle();
                 this.autoCompleteMode = autoCompleteMode;
             }
             if (this.AutoCompleteSource == System.Windows.Forms.AutoCompleteSource.CustomSource)
             {
                 if (base.IsHandleCreated && (this.AutoCompleteCustomSource != null))
                 {
                     if (this.AutoCompleteCustomSource.Count == 0)
                     {
                         this.ResetAutoComplete(true);
                     }
                     else if (this.stringSource != null)
                     {
                         this.stringSource.RefreshList(this.GetStringsForAutoComplete());
                     }
                     else
                     {
                         this.stringSource = new StringSource(this.GetStringsForAutoComplete());
                         if (!this.stringSource.Bind(new HandleRef(this, base.Handle), (int) this.AutoCompleteMode))
                         {
                             throw new ArgumentException(System.Windows.Forms.SR.GetString("AutoCompleteFailure"));
                         }
                     }
                 }
             }
             else
             {
                 try
                 {
                     if (base.IsHandleCreated)
                     {
                         int num = 0;
                         if (this.AutoCompleteMode == System.Windows.Forms.AutoCompleteMode.Suggest)
                         {
                             num |= -1879048192;
                         }
                         if (this.AutoCompleteMode == System.Windows.Forms.AutoCompleteMode.Append)
                         {
                             num |= 0x60000000;
                         }
                         if (this.AutoCompleteMode == System.Windows.Forms.AutoCompleteMode.SuggestAppend)
                         {
                             num |= 0x10000000;
                             num |= 0x40000000;
                         }
                         System.Windows.Forms.SafeNativeMethods.SHAutoComplete(new HandleRef(this, base.Handle), ((int) this.AutoCompleteSource) | num);
                     }
                 }
                 catch (SecurityException)
                 {
                 }
             }
         }
         else if (reset)
         {
             this.ResetAutoComplete(true);
         }
     }
 }
 private void SetAutoComplete(bool reset, bool recreate)
 {
     if (base.IsHandleCreated && (this.childEdit != null))
     {
         if (this.AutoCompleteMode != System.Windows.Forms.AutoCompleteMode.None)
         {
             if ((!this.fromHandleCreate && recreate) && base.IsHandleCreated)
             {
                 System.Windows.Forms.AutoCompleteMode autoCompleteMode = this.AutoCompleteMode;
                 this.autoCompleteMode = System.Windows.Forms.AutoCompleteMode.None;
                 base.RecreateHandle();
                 this.autoCompleteMode = autoCompleteMode;
             }
             if (this.AutoCompleteSource == System.Windows.Forms.AutoCompleteSource.CustomSource)
             {
                 if (this.AutoCompleteCustomSource != null)
                 {
                     if (this.AutoCompleteCustomSource.Count == 0)
                     {
                         int flags = -1610612736;
                         System.Windows.Forms.SafeNativeMethods.SHAutoComplete(new HandleRef(this, this.childEdit.Handle), flags);
                     }
                     else if (this.stringSource != null)
                     {
                         this.stringSource.RefreshList(this.GetStringsForAutoComplete(this.AutoCompleteCustomSource));
                     }
                     else
                     {
                         this.stringSource = new StringSource(this.GetStringsForAutoComplete(this.AutoCompleteCustomSource));
                         if (!this.stringSource.Bind(new HandleRef(this, this.childEdit.Handle), (int) this.AutoCompleteMode))
                         {
                             throw new ArgumentException(System.Windows.Forms.SR.GetString("AutoCompleteFailure"));
                         }
                     }
                 }
             }
             else if (this.AutoCompleteSource == System.Windows.Forms.AutoCompleteSource.ListItems)
             {
                 if (this.DropDownStyle == ComboBoxStyle.DropDownList)
                 {
                     int num3 = -1610612736;
                     System.Windows.Forms.SafeNativeMethods.SHAutoComplete(new HandleRef(this, this.childEdit.Handle), num3);
                 }
                 else if (this.itemsCollection != null)
                 {
                     if (this.itemsCollection.Count == 0)
                     {
                         int num2 = -1610612736;
                         System.Windows.Forms.SafeNativeMethods.SHAutoComplete(new HandleRef(this, this.childEdit.Handle), num2);
                     }
                     else if (this.stringSource != null)
                     {
                         this.stringSource.RefreshList(this.GetStringsForAutoComplete(this.Items));
                     }
                     else
                     {
                         this.stringSource = new StringSource(this.GetStringsForAutoComplete(this.Items));
                         if (!this.stringSource.Bind(new HandleRef(this, this.childEdit.Handle), (int) this.AutoCompleteMode))
                         {
                             throw new ArgumentException(System.Windows.Forms.SR.GetString("AutoCompleteFailureListItems"));
                         }
                     }
                 }
             }
             else
             {
                 try
                 {
                     int num4 = 0;
                     if (this.AutoCompleteMode == System.Windows.Forms.AutoCompleteMode.Suggest)
                     {
                         num4 |= -1879048192;
                     }
                     if (this.AutoCompleteMode == System.Windows.Forms.AutoCompleteMode.Append)
                     {
                         num4 |= 0x60000000;
                     }
                     if (this.AutoCompleteMode == System.Windows.Forms.AutoCompleteMode.SuggestAppend)
                     {
                         num4 |= 0x10000000;
                         num4 |= 0x40000000;
                     }
                     System.Windows.Forms.SafeNativeMethods.SHAutoComplete(new HandleRef(this, this.childEdit.Handle), ((int) this.AutoCompleteSource) | num4);
                 }
                 catch (SecurityException)
                 {
                 }
             }
         }
         else if (reset)
         {
             int num5 = -1610612736;
             System.Windows.Forms.SafeNativeMethods.SHAutoComplete(new HandleRef(this, this.childEdit.Handle), num5);
         }
     }
 }
 protected override void OnHandleDestroyed(EventArgs e)
 {
     this.dropDownHandle = IntPtr.Zero;
     if (base.Disposing)
     {
         this.itemsCollection = null;
         this.selectedIndex = -1;
     }
     else
     {
         this.selectedIndex = this.SelectedIndex;
     }
     if (this.stringSource != null)
     {
         this.stringSource.ReleaseAutoComplete();
         this.stringSource = null;
     }
     base.OnHandleDestroyed(e);
 }
Beispiel #12
0
 void IEnumString.Clone(out IEnumString ppenum)
 {
     ppenum = new StringSource(strings);
 }
Beispiel #13
0
        /// <include file='doc\TextBox.uex' path='docs/doc[@for="TextBox.SetAutoComplete"]/*' />
        /// <devdoc>
        ///     Sets the AutoComplete mode in TextBox.
        /// </devdoc>
        internal void SetAutoComplete(bool reset)
        {
            //Autocomplete Not Enabled for Password enabled and MultiLine Textboxes.
            if (Multiline || passwordChar != 0 || useSystemPasswordChar || AutoCompleteSource == AutoCompleteSource.None)
            {
                return;
            }

            if (AutoCompleteMode != AutoCompleteMode.None)
            {
                if (!fromHandleCreate)
                {
                    //RecreateHandle to avoid Leak.
                    // notice the use of member variable to avoid re-entrancy
                    AutoCompleteMode backUpMode = this.AutoCompleteMode;
                    autoCompleteMode = AutoCompleteMode.None;
                    RecreateHandle();
                    autoCompleteMode = backUpMode;
                }

                if (AutoCompleteSource == AutoCompleteSource.CustomSource)
                {
                    if (IsHandleCreated && AutoCompleteCustomSource != null)
                    {
                        if (AutoCompleteCustomSource.Count == 0)
                        {
                            ResetAutoComplete(true);
                        }
                        else
                        {
                            if (stringSource == null)
                            {
                                stringSource = new StringSource(GetStringsForAutoComplete());
                                if (!stringSource.Bind(new HandleRef(this, Handle), (int)AutoCompleteMode))
                                {
                                    throw new ArgumentException(SR.GetString(SR.AutoCompleteFailure));
                                }
                            }
                            else
                            {
                                stringSource.RefreshList(GetStringsForAutoComplete());
                            }
                        }
                    }
                }
                else
                {
                    try {
                        if (IsHandleCreated)
                        {
                            int mode = 0;
                            if (AutoCompleteMode == AutoCompleteMode.Suggest)
                            {
                                mode |= NativeMethods.AUTOSUGGEST | NativeMethods.AUTOAPPEND_OFF;
                            }
                            if (AutoCompleteMode == AutoCompleteMode.Append)
                            {
                                mode |= NativeMethods.AUTOAPPEND | NativeMethods.AUTOSUGGEST_OFF;
                            }
                            if (AutoCompleteMode == AutoCompleteMode.SuggestAppend)
                            {
                                mode |= NativeMethods.AUTOSUGGEST;
                                mode |= NativeMethods.AUTOAPPEND;
                            }
                            int ret = SafeNativeMethods.SHAutoComplete(new HandleRef(this, Handle), (int)AutoCompleteSource | mode);
                        }
                    }
                    catch (SecurityException) {
                        // If we don't have full trust, degrade gracefully. Allow the control to
                        // function without auto-complete. Allow the app to continue running.
                    }
                }
            }
            else if (reset)
            {
                ResetAutoComplete(true);
            }
        }