Strange behavior with tooltips

Hi there,
I'm having a strange problem:
First I show a dialog form (frmMain). Inside the main form I show a non-dialog child form (frmStatVn) which has a tooltip for a textbox with its IsBalloon property set to true.
After I close frmStatVn if I click a menu option of the main form an exception occurs at the frmMain.ShowDialog() line:
"Object reference not set to an instance of an object."
Details:
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.ToolTip.CreateHandle()
at System.Windows.Forms.ToolTip.get_Handle()
at System.Windows.Forms.ToolTip.WmWindowPosChanging(Message& m)
at System.Windows.Forms.ToolTip.WndProc(Message& msg)
at System.Windows.Forms.ToolTip.ToolTipNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at POS.Program.Main() in C:\Documents and Settings\User\My documents\Visual Studio 2005\Projects\Invoice\Invoice\Program.cs:line 30
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

My Program.cs: (as suggested by nobugz in another thread)
for (; ; )
{
frmLogin _frmLogin = new frmLogin();
if (_frmLogin.ShowDialog() != DialogResult.OK) break;
_frmLogin.Dispose();

frmMain _frmMain = new frmMain();
if (_frmMain.ShowDialog() != DialogResult.OK) break;
_frmMain.Dispose();
}

The strange thing is that I have 12 forms using tooltips. I use the tooltips the same way in those 12 forms but the exception occurs only with 5 of those forms (frmStatVn is one of those 5 forms).
Something funny is that if I set the IsBalloon property to false in those 5 forms the exception never happens.
I have reviewed the other 7 forms to check differences, but in all those 12 forms I use the tooltips exactly the same.

Is this a bug or am I missing something

Thanks in advance


Answer this question

Strange behavior with tooltips

  • Strange behavior with tooltips