Subclass combo box

G

gregl

I have a strange problem with my custom combo box. It happens on the
KeyUp event when tabbing into the control, or when typing characters
into the combo.

Here is the code for the custom combo's KeyUp:

Private Sub MyCombo_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
Try
If e.KeyCode = Keys.Enter Then
RaiseEvent EnterKeyHit(sender, New System.EventArgs)
Exit Sub
End If
If e.KeyCode = Keys.Tab Then Exit Sub

Dim i As Integer = MyBase.SelectionStart
Me.Text = Me.Text.ToUpper
Dim s As String = MyBase.Text
If i > 0 Then
MyBase.SelectedIndex = MyBase.FindString(s)
MyBase.Select(i, MyBase.Text.Length - i)
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

The problem occurs at this point: "MyBase.Select(i, MyBase.Text.Length
- i)"
Specifically when it gets the length. I get an error such as this:

************** Exception Text **************
System.ArgumentException: '-5943193' is not a valid value for 'length'.
at System.Windows.Forms.ComboBox.Select(Int32 start, Int32 length)
at System.Windows.Forms.ComboBox.set_SelectionStart(Int32 value)
at CoreUserCtrls.CoreCombo.CoreCombo_KeyUp(Object sender,
KeyEventArgs e)
at System.Windows.Forms.Control.OnKeyUp(KeyEventArgs e)
at System.Windows.Forms.Control.ProcessKeyEventArgs(Message& m)
at System.Windows.Forms.Control.ProcessKeyMessage(Message& m)
at System.Windows.Forms.Control.WmKeyChar(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ComboBox.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)
*******************************************************************************************

The bogus length is not always the same number.

I have found that certain processes running on the system seem to cause
the issue. Specifically the ones I know about right now are
"OPWARE12.EXE" which is some type of OmniPage text filter. I've also
seen this with a certain AOL dialer process of which I don't have the
exact name of at the moment.

Since I'm seeing this with more than one background process, I'm
concerned there are others I have not found yet. I'm hoping someone
has seen this issue and can provide some insight. Thanks.

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top