Not sure why you're making the handle of the active document window the owner of
your WindowInteropHelper.
You're not making clear the context your code runs in.
Is it a called from a command handler? If so, what are
the CommandFlags specified in the CommandMethod
attribute?
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011
http://www.acadxtabs.com
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
wrote in message news:6388878@discussion.autodesk.com...
Good afternoon,
I have a modeless command set up, using the managed API to create a large number
of entities (think 5000+) based on external data provided by a point-of-sales
program. Currently this command uses Windows.Forms to display a modeless dialog
that notifies the user about its progress (which works just fine).
I've been trying (and failing) to rewrite the interface as window under WPF.
My first attempt was as follows:
{code}
Dim Splash as New SplashDialog() 'Inherits from System.Windows.Window
Dim WPF As New Windows.Interop.WindowInteropHelper(Splash)
WPF.Owner = AcAp.Application.DocumentManager.MdiActiveDocument.Window.Handle
Splash.Show()
{code}
What I noticed was that any delegates invoked through the splash window's
Dispatcher would not update the UI. I think this is because this window is on
the same thread as my command. Therefore the UI won't update until my thread is
complete (not what I want).
I also tried creating the window on a new thread:
{code}
Protected Shared Splash As SplashDialog() 'Inherits from System.Windows.Window
Protected Shared WithEvents Worker As New
System.ComponentModel.BackgroundWorker()
Protected Shared Sub Work(ByVal Sender As Object, ByVal e As
System.ComponentModel.DoWorkEventArgs) Handles Worker.DoWork
Splash = New SplashDialog()
Dim WPF As New Windows.Interop.WindowInteropHelper(Splash)
WPF.Owner = AcAp.Application.DocumentManager.MdiActiveDocument.Window.Handle
Splash.Show()
System.Windows.Threading.Dispatcher.Run()
End Sub
{code}
The above approach also doesn't work. The variable holding a reference to the
form is null, and I think it's because the main thread isn't waiting for the UI
thread to finish initializing the new window.
Any advice?
Regards,
JB