WindowWorkspace focusing and sizing

Topics: CAB & Smart Client Software Factory
Mar 18, 2006 at 12:18 AM
originally posted by: atome

Hi there,

I'm really new to CAB, so excuse me if my question seems stupid :

I don't know how to manage focusing and sizing when using a WindowWorkspace. For example, I have a SmartPart user control (400*200), and I want to display it in a WindowWorkspace. How can I size this workspace ?

I've try the following code in order to set the correct size, and set focus to the WindowWorkspace if it already exists :

public void Show(IWorkspace parentWorkspace, ISmartPartInfo info)
{
// Create or get the view
editContactView = editContactView ?? Items.AddNew<EditContactView>();

// Display the view in workspace
this.parentWorkspace = parentWorkspace;
parentWorkspace.Show(editContactView,info);

// Crapy code to set size of the WindowWorkspace and force focus
editContactView.Dock = System.Windows.Forms.DockStyle.Fill;
editContactView.Parent.ClientSize = editContactView.Size;
editContactView.Parent.Focus();

}

Is there a smarter way to do this ? I wonder how to manage windowworkspace positionning too, using something like "ParentCenter", "MidScreen", etc., and not only the SmartPartInfo.Position.

Thanks in advance,

Romain.