proper closing of WindowWorkspace

Topics: CAB & Smart Client Software Factory
Oct 20, 2006 at 4:34 PM
originally posted by: cristoforo

When I close the WindowWorkspace then reshow it I get this error "Window handle already exists" . The MyView/UserControl consists other Views/UserControls. I used the code below to show the MyView in the WindowWorkspace. How to get rid of this error? tnx a lot.

dim ws as WindowWorkspace
dim myView as MyView
dim myViewInfo as WindowSmartPartInfo

public sub ShowForm()

If ws Is Nothing Then
ws = me.WorkItem.Workspaces.AddNew(Of WindowWorkspace)()
End If

If myView Is Nothing Then
myView = me.WorkItem.SmartParts.AddNew(Of MyView )()
End If

If myViewInfo Is Nothing Then
myViewInfo = me.WorkItem.SmartParts.AddNew(Of WindowSmartPartInfo)()
With myViewInfo
.Title = "Problematic Form"
.Modal = True
.Height = myView.Height + 40
.Width = 779
Me.myView .Dock = DockStyle.Fill
End With
End If

ws.Show(myView , myViewInfo )

end sub
Oct 27, 2006 at 6:32 AM
originally posted by: pcfountain

I was having similar problems handling the closing of WindowWorkspace. I discovered that using the Hide method works nicely. You have to pass in a reference to the view that is currently showing in that WindowWorkspace. According to the help file, it disposes the view, and the WindowWorkspace is hidden for later use.

(my code is in C#, hopefully you can get the idea)

MyView view = WorkItem.SmartParts.Get(viewId);