Getting Shell reference from a Workitem

Topics: CAB & Smart Client Software Factory
Mar 31, 2006 at 4:03 AM
originally posted by: atome


Is there a way to retrieve a reference to the application main form (eg : MyShellApplication.Shell) from a module workitem ?

In fact, in a module, I have a workitem which creates and displays a window (eg: Contact edition form). I would like to set the parent of this form to the main application window, in order to display it well centered.

Thank you.

Mar 31, 2006 at 4:11 AM
originally posted by: BradWilsonMSFT

No, there is no way to get access to the shell.

In general, "access to the shell" should mean getting access to the Workspaces and UI extension sites in the shell, which you can get to via the WorkItem.
Mar 31, 2006 at 4:38 AM
originally posted by: DLorenz

Well, if you have to have access to the shell, you could create a service that returns MyBase.Shell in the FormShellApplication. If you don't want to make a service, you could always put a reference to MyBase.Shell in the top level workitem's state.
Mar 31, 2006 at 5:13 AM
originally posted by: atome

Thank you for answering !

I'll try to do something like that.

Apr 8, 2006 at 5:44 AM
originally posted by: sklett

There is a perfect (I think) example of this in the AppraiserWorkbench. Look at IMessageBoxService in the Common project and ShellMessageBoxService in the shell app.
Apr 8, 2006 at 9:44 AM
originally posted by: zwzhang28

I did it like this:

First, do we really need the ShellForm reference? Usually all we need is to do something that requires directly access to the shell from. So how about a service.

1. Define IShellService

2. ShellForm implement this interface, or a shell controler with a reference to shell implements

3. Add this service as IShellService to RootworkItem.Services

4. The service is then always available through the whole application
(******.workitem.RootWorkitem.Services.get<'IShellService'>(); is one way as an example)