<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Identify the Start Tab (Autocad 2016) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/identify-the-start-tab-autocad-2016/m-p/7293705#M30174</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Is the start tab a document?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, it is not a document. It is DocumentWindow, which has a property "Document", which is an "object", which can only be Autodesk.AutoCAD.ApplicationServices.Document when the DocumentWindow is drawing window. When it is "Start", or custom window (yes, you can create one of your own), then the "Document" property is anything else, but an Autodesk.AutoCAD.Application.Document.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;Is there a way to identify that the user has clicked on the start tab?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, you can identify if the active DocumentWindow is a drawing window or "Start"/custom window. Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if (Application.DocumentWindowCollection.Count&amp;gt;0)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var doc = Application.DocumentWindowCollection.ActiveDocumentWindow.Document;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if (!(doc is Autodesk.AutoCAD.ApplicationServices.Document)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var msg=string.Format("This is non-drawing window: \"{0}\"", Application.DocumentWindowCollection,ActiveDocumentWindow.Title);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;CadApp.ShowAlert(msg);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; //There isn't any DocumentWindow open!&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it is likely that in your DocumentCollection.DocumentBecameCurrent event handler, you do not need to identify whether user clicked "Start" tab or not (you could, if you choose to do so, of course), and simply&amp;nbsp;let the code, as Activist_Investor pointed out, test if the MdiActiveDocument is null or not, before using it. You may want to show your code to indicate where the crash occurs.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Aug 2017 13:04:23 GMT</pubDate>
    <dc:creator>Norman_Yuan</dc:creator>
    <dc:date>2017-08-11T13:04:23Z</dc:date>
    <item>
      <title>Identify the Start Tab (Autocad 2016)</title>
      <link>https://forums.autodesk.com/t5/net-forum/identify-the-start-tab-autocad-2016/m-p/7292006#M30172</link>
      <description>&lt;P&gt;I have a program that implements a documentbecamecurrent handler. In this I access the current documents database. When I click on the Start Tab it fires the event handler then crashes when I try to access the document database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is the start tab a document?&lt;/P&gt;&lt;P&gt;Is there a way to identify that the user has clicked on the start tab?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 21:09:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/identify-the-start-tab-autocad-2016/m-p/7292006#M30172</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-10T21:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Identify the Start Tab (Autocad 2016)</title>
      <link>https://forums.autodesk.com/t5/net-forum/identify-the-start-tab-autocad-2016/m-p/7292519#M30173</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;I have a program that implements a documentbecamecurrent handler. In this I access the current documents database. When I click on the Start Tab it fires the event handler then crashes when I try to access the document database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is the start tab a document?&lt;/P&gt;&lt;P&gt;Is there a way to identify that the user has clicked on the start tab?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Crashes with? &amp;nbsp;A NullReferenceException ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If so, you have to first check the Document to ensure it's not null before you try to use it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 02:02:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/identify-the-start-tab-autocad-2016/m-p/7292519#M30173</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-11T02:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Identify the Start Tab (Autocad 2016)</title>
      <link>https://forums.autodesk.com/t5/net-forum/identify-the-start-tab-autocad-2016/m-p/7293705#M30174</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Is the start tab a document?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, it is not a document. It is DocumentWindow, which has a property "Document", which is an "object", which can only be Autodesk.AutoCAD.ApplicationServices.Document when the DocumentWindow is drawing window. When it is "Start", or custom window (yes, you can create one of your own), then the "Document" property is anything else, but an Autodesk.AutoCAD.Application.Document.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;Is there a way to identify that the user has clicked on the start tab?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, you can identify if the active DocumentWindow is a drawing window or "Start"/custom window. Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if (Application.DocumentWindowCollection.Count&amp;gt;0)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var doc = Application.DocumentWindowCollection.ActiveDocumentWindow.Document;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if (!(doc is Autodesk.AutoCAD.ApplicationServices.Document)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var msg=string.Format("This is non-drawing window: \"{0}\"", Application.DocumentWindowCollection,ActiveDocumentWindow.Title);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;CadApp.ShowAlert(msg);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; //There isn't any DocumentWindow open!&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it is likely that in your DocumentCollection.DocumentBecameCurrent event handler, you do not need to identify whether user clicked "Start" tab or not (you could, if you choose to do so, of course), and simply&amp;nbsp;let the code, as Activist_Investor pointed out, test if the MdiActiveDocument is null or not, before using it. You may want to show your code to indicate where the crash occurs.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 13:04:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/identify-the-start-tab-autocad-2016/m-p/7293705#M30174</guid>
      <dc:creator>Norman_Yuan</dc:creator>
      <dc:date>2017-08-11T13:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: Identify the Start Tab (Autocad 2016)</title>
      <link>https://forums.autodesk.com/t5/net-forum/identify-the-start-tab-autocad-2016/m-p/7299111#M30175</link>
      <description>&lt;P&gt;Thanks for your help guys.&amp;nbsp;It was a null reference exception and testing MdiActiveDocument for null is what I needed.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 16:06:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/identify-the-start-tab-autocad-2016/m-p/7299111#M30175</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-14T16:06:32Z</dc:date>
    </item>
  </channel>
</rss>

