A LoginFormActivity uses InArgument<IntPtr> Handle to set the LoginForm parent to the client host application window handle. For example, a SharePoint login form can be displayed as a child window of the Word application window handle.

  [Designer(typeof(MyData.Activities.Designers.LoginFormActivityDesigner))]
  public sealed class LoginFormActivity : CodeActivity
  {
    public InArgument<IntPtr> Handle {get; set;}

    public OutArgument<ICredentials> NetworkCredential { get; set; }

    private ICredentials _networkCredential;

    protected override void Execute(CodeActivityContext context)
    {    
      IntPtr handle = Handle.Get(context);

      LoginForm form = new LoginForm();
      form.DataAvailable += new LoginForm.ActivityFormEventHandler(form_DataAvailable);    
      form.ShowDialog(new MyWin32Window(handle));

      NetworkCredential.Set(context, _networkCredential);

    }

    //Get the users credentials
    void form_DataAvailable(object sender, ActivityFormEventArgs e)
    {
      _networkCredential = e.NetworkCredential;
    }
  }

  public class MyWin32Window : IWin32Window
  {
    private IntPtr _hwnd;

    public MyWin32Window(IntPtr handle)
    {
      _hwnd = handle;
    }

    public IntPtr Handle
    {
      get
      {
        return _hwnd;
      }
    }
  }

Last edited Oct 10, 2011 at 12:50 AM by dvana, version 3

Comments

No comments yet.