Thank you for your suggestion, Jim - quick as always!
But I wouldn't have thought it could possibly make a difference (and it didn't) because if the DialogForm didn't have a ThesaurusControl assigned to begin with how would it have worked perfectly every time except for the very first call?
I replaced the call to Show() with a call to ShowDialog() and am now running into this exception:
System.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex, Int32 length)
at Keyoti.Thesaurus.Windows.Thesaurus.GetWord(Int32 caretPosition, Int32 selectionLength, String text)
at Keyoti.Thesaurus.Windows.Thesaurus.OnDialogLoad(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
This happens after right-clicking a word in TXTextControl and selecting the menu entry thesaurus which calls your dialog as described before.
Wolfgang
Wolfgang