Closing last window with middle clicking the document tab throws an exception

5 posts, 1 answers
  1. Constantinos Petridis
    Constantinos Petridis avatar
    16 posts
    Member since:
    May 2010

    Posted 05 Mar 2012 Link to this post

    Good afternoon Telerik team :)

    I've been testing the new version of Telerik's RadDock control (2012 Q1) and I seem to have found a problem when closing the last document by middle clicking its tab.

    An Unhandled null reference exception is thrown with the following stack trace:

    See the end of this message for details on invoking 
    just-in-time (JIT) debugging instead of this dialog box.


    ************** Exception Text **************
    System.NullReferenceException: Object reference not set to an instance of an object.
       at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
       at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at Telerik.WinControls.RadControl.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)




    ************** Loaded Assemblies **************
    mscorlib
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.239 (RTMGDR.030319-2300)
        CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
    ----------------------------------------
    RadDockPRoblem
        Assembly Version: 1.0.0.0
        Win32 Version: 1.0.0.0
        CodeBase: file:///C:/Projects/RadDockProblem/bin/Debug/RadDockPRoblem.exe
    ----------------------------------------
    System.Windows.Forms
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.235 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
    ----------------------------------------
    System.Drawing
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 built by: RTMRel
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
    ----------------------------------------
    System
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.232 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------
    System.Configuration
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
    ----------------------------------------
    System.Xml
        Assembly Version: 4.0.0.0
        Win32 Version: 4.0.30319.225 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
    ----------------------------------------
    Telerik.WinControls.UI
        Assembly Version: 2012.1.12.215
        Win32 Version: 2012.1.12.0215
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Telerik.WinControls.UI/2012.1.12.215__5bb2a467cbec794e/Telerik.WinControls.UI.dll
    ----------------------------------------
    Telerik.WinControls.RadDock
        Assembly Version: 2012.1.12.215
        Win32 Version: 2012.1.12.0215
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Telerik.WinControls.RadDock/2012.1.12.215__5bb2a467cbec794e/Telerik.WinControls.RadDock.dll
    ----------------------------------------
    Telerik.WinControls
        Assembly Version: 2012.1.12.215
        Win32 Version: 2012.1.12.0215
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Telerik.WinControls/2012.1.12.215__5bb2a467cbec794e/Telerik.WinControls.dll
    ----------------------------------------
    TelerikCommon
        Assembly Version: 2012.1.12.215
        Win32 Version: 2012.1.12.0215
        CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/TelerikCommon/2012.1.12.215__5bb2a467cbec794e/TelerikCommon.dll
    ----------------------------------------
    al30nzul
        Assembly Version: 2012.1.12.215
        Win32 Version: 4.0.30319.232 built by: RTMGDR
        CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
    ----------------------------------------


    ************** JIT Debugging **************
    To enable just-in-time (JIT) debugging, the .config file for this
    application or computer (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.


    For example:


    <configuration>
        <system.windows.forms jitDebugging="true" />
    </configuration>


    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the computer
    rather than be handled by this dialog box.

    All other ways of closing a document seem to work just fine (ctrl-F4, close button on tab, close button on document's tab strip, selecting close or close all by right clicking the tab etc). If you try to perform this action while Designing the form (in VS2010), the instance of Visual Studio will close without warning.

    I am attaching a sample project, just compile & run and try to close the document window by middle clicking on the window's tab header.
    I was trying to find a way to disable this functionality (close window by middle clicking the document's tab) but I could not find any, do you have any suggestions?

  2. Constantinos Petridis
    Constantinos Petridis avatar
    16 posts
    Member since:
    May 2010

    Posted 06 Mar 2012 Link to this post

    I issued a support ticket for this problem but I think I found a workaround that seems to work until a fix is introduced by Telerik.
    After seeing the actual source code of Telerik.WinControls.ComponentInputBehavior.OnMouseUp function, I tried to set the DisableMouseEvents of the Behavior Object in DockWindow.DockTabStrip to true for the last document in the closing documents DockTabStrip. This is the code snippet.

    private void radDock1_DockWindowClosing(object sender, Telerik.WinControls.UI.Docking.DockWindowCancelEventArgs e)
    {
          if (e.NewWindow.DockTabStrip.TabPanels.Count == 1)
              e.NewWindow.DockTabStrip.Behavior.DisableMouseEvents = true;
    }

    Disabling the mouse events for DockTabStrip will skip the execution of code that generates the unhandled null reference exception. I just hope that this does not introduce a problem somewhere else in the docking mechanism.

  3. Answer
    Boryana
    Admin
    Boryana avatar
    330 posts
    Member since:
    Sep 2012

    Posted 07 Mar 2012 Link to this post

    Hi Constantinos,

    Thank you for the detailed explanation and the sample project. They were of great help.

    I confirm that there is an issue with closing the last TabbedDocument using middle click. I have logged it in our Public Issue Tracker under ID 10076. To vote for it and subscribe for its stats updates please follow this link: http://www.telerik.com/support/pits.aspx#/public/winforms/10076

    Currently, the only workaround is subscribe to the DocumentTabStrip MouseClick event and raise a flag if the used button is middle. Further, you can cancel the document closing in DockWindowClosing even handler depending on the flag's value. For example: 

    public Form1()
    {
        InitializeComponent();
        this.radDock1.DockWindowClosing += new DockWindowCancelEventHandler(radDock1_DockWindowClosing);
        DocumentTabStrip a = this.radDock1.GetDefaultDocumentTabStrip(false);
        a.MouseClick += new MouseEventHandler(a_MouseClick);
    }
     
    void radDock1_DockWindowClosing(object sender, DockWindowCancelEventArgs e)
    {
        if (middleClick)
        {
            e.Cancel = true;
            middleClick = false;
        }
    }
     
    void a_MouseClick(object sender, MouseEventArgs e)
    {
        if (e.Button == System.Windows.Forms.MouseButtons.Middle)
        {
            middleClick = true;
        }
    }

    Thank you for reporting this issue and please excuse us for the caused inconvenience. Our team will do its best to address the issue in a future release. Your Telerik points have been updated for this report.

    Regards,
    Boryana
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>

  4. daouddajani
    daouddajani avatar
    6 posts
    Member since:
    Apr 2007

    Posted 17 Jul 2012 Link to this post

    I have the same problem when i close the winform by double click on a radGrid row
    my application allows me to double click a radgrid row to choose it then closes the windows and places the value in the parent window.

    after i upgraded to Q1 2012 the problem started and even in Q2 2012 its the same.

    any help please


    System.NullReferenceException was unhandled
      Message=Object reference not set to an instance of an object.
      Source=Telerik.WinControls
      StackTrace:
           at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
           at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
           at Telerik.WinControls.UI.RadGridView.OnMouseUp(MouseEventArgs e)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
           at Telerik.WinControls.RadControl.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
           at SalesForce2011.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
      InnerException:

  5. Boryana
    Admin
    Boryana avatar
    330 posts
    Member since:
    Sep 2012

    Posted 19 Jul 2012 Link to this post

    Hello,

    Thank you for writing.

    My attempts to reproduce the issue you experience were not successful. Would you please share your specific implementation through pasting code snippets? Alternatively, you can open a new support ticket and attach your project there. Once I am able to replicate the exception on my side I will do my best to provide you with proper support.

    I am looking forward to your reply.

    All the best,
    Boryana
    the Telerik team

    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>

Back to Top