<?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: MainWindow to System.Windows.Window in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5209117#M44737</link>
    <description>&lt;P&gt;Wouldn't the "Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog/Window()" suppose to show a window floting on top of AutoCAD main window, but not on top other windows applications?&lt;/P&gt;</description>
    <pubDate>Tue, 12 Aug 2014 13:38:26 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2014-08-12T13:38:26Z</dc:date>
    <item>
      <title>MainWindow to System.Windows.Window</title>
      <link>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/4922284#M44733</link>
      <description>&lt;P&gt;I'm trying to set the OwnerWindow-proerty on our License system to ensure that any dialog from the license system is displayed in the foreground. This system expects a System.Windows.Window object, but AutoCAD only provides a Autodesk.AutoCAD.Windows.Window-property as far as I can see (Application.MainWindow)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I've tried casting it, to no luck, and I've tried to convert it using:&amp;nbsp;&lt;SPAN&gt;HwndSource.FromHwnd(Application.MainWindow.Handle); -But it returns null.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there another way this can be done?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;(I have one work-around wich uses Application.ShowModelessWindow on a temp wpf window, which in turn is used as owner window for the license system, but it's less than ideal..&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2014 10:19:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/4922284#M44733</guid>
      <dc:creator>ow</dc:creator>
      <dc:date>2014-03-31T10:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: MainWindow to System.Windows.Window</title>
      <link>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/4942304#M44734</link>
      <description>&lt;P&gt;Sorry for the delay.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;AutoCAD main window is MFC based the .Net API is a wrapper around it which provides access to the window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, type casting to System.Windows.Window is not valid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The workaround that you already mentioned which uses a WPF window is the way to get around it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2014 08:49:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/4942304#M44734</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2014-04-08T08:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: MainWindow to System.Windows.Window</title>
      <link>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5208607#M44735</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm also facing this problem in another context. I'm writing Plugins for Acad, which use WPF windows as UI. If I set the "Topmost" property of my WPF-Window, it stays on top of everything, since I cannot declare the acad Window as parent/owner - i guess.&lt;/P&gt;&lt;P&gt;So with the plugin runnig and opening an Explorer Window this will be overlaid by my form... This is annoying and not really professional.... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'd like to show it on top of Acad only (modeless windows, though) but not on top of anything else....&lt;/P&gt;&lt;P&gt;Is there really no way, to show those Windows in the expected manner? Or am I just missing something?&lt;/P&gt;&lt;P&gt;Any hints are appreciated.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2014 09:05:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5208607#M44735</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-08-12T09:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: MainWindow to System.Windows.Window</title>
      <link>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5208811#M44736</link>
      <description>&lt;P&gt;Since AutoCAD main window is MFC based which is native window, we should use&amp;nbsp;NativeWindow class to wrap it in .NET and set it is a parent of your plugin window. The following code will help:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;private void ShowModelessWindow()
{
    // Replace with your plugin WPF window
    var pluginForm = new System.Windows.Forms.Form();

    // Get AutoCAD main window handle
    IntPtr acadHandle = Application.MainWindow.Handle;&lt;BR /&gt;&lt;BR /&gt;    // Create a new .NET native window wrapper of AutoCAD
    var nativeWindow = new System.Windows.Forms.NativeWindow();
    nativeWindow.AssignHandle(acadHandle);

    // Show the plugin on top of AutoCAD
    pluginForm.Show(nativeWindow);
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2014 11:28:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5208811#M44736</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-08-12T11:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: MainWindow to System.Windows.Window</title>
      <link>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5209117#M44737</link>
      <description>&lt;P&gt;Wouldn't the "Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog/Window()" suppose to show a window floting on top of AutoCAD main window, but not on top other windows applications?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2014 13:38:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5209117#M44737</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2014-08-12T13:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: MainWindow to System.Windows.Window</title>
      <link>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5209231#M44738</link>
      <description>&lt;P&gt;Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog is a built-in method in AutoCAD. While NativeWindow.FromHandle (static method of (new NativeWindow()).AssignHandle) is the generic method to show a modeless form on top of a&amp;nbsp;specified host application. I guess they will work the same. If not, try the generic method.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2014 14:13:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5209231#M44738</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-08-12T14:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: MainWindow to System.Windows.Window</title>
      <link>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5256753#M44739</link>
      <description>&lt;P&gt;To cast Application.MainWindow.Handle to a Win32 HWND you can use the following class&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using System;&lt;BR /&gt;using Autodesk.AutoCAD.ApplicationServices.Core;&lt;/P&gt;&lt;P&gt;namespace Utility&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; class AcadMainWindow : System.Windows.Forms.IWin32Window&lt;BR /&gt;&amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public IntPtr Handle&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get { return Application.MainWindow.Handle; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then you can use a new AcadMainWindow() object in place of any MFC/Win32 HWND&lt;/P&gt;</description>
      <pubDate>Fri, 05 Sep 2014 17:43:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mainwindow-to-system-windows-window/m-p/5256753#M44739</guid>
      <dc:creator>MexicanCustard</dc:creator>
      <dc:date>2014-09-05T17:43:30Z</dc:date>
    </item>
  </channel>
</rss>

