External Hosted Application - Opens new window

Nov 15, 2010 at 5:47 AM

Hi,

I have configured an external hosted application (desktop application). i have automated the login process. Once successfully logged into the application, the application opens the main window as new window.

How can i bring this window inside CCA?

Thanks,

Senthil

Nov 22, 2010 at 5:54 AM

Hi,

Even i have the same requirement.Please let me know if anybody comes up with solution.

Thanks in advance

-Prashanth

 

Nov 22, 2010 at 6:47 AM

Hello.

Maybe this will help.

http://crmcca.codeplex.com/Thread/View.aspx?ThreadId=223378

Vahag.

Dec 31, 2010 at 5:49 PM

Hi,

I realised whilst hosting a demo .Net forms app within IAD that if the optimal size of the app is specified to be greater than that the IAD can accomodate, it opens the app in a new window rather than within the IAD session. Perhaps this might be one of the many causes for the application to be opened in a new window.

Aman

Jan 10, 2011 at 1:46 PM

Hi All,

I went through the link provided by Vahag. 

That seems to be a Web application where he needs to navigate from one CRM page to another where the new window pops up out side the AD.

As per  the requirement of senthijps, i also have a windows application hosted with a Login Page. The login page is dispalyed inside the AD. But, after clicking on Login and when a new screen is invoked its opened in a new screen outside AD. Can anyone help with the ways of integrating the new window inside the AgentDesktop.

Thanks,

Amaran

 

Jan 14, 2011 at 2:43 PM

You will need to reacquire the new window ( post login ) and ReHost it inside the Adapter.  
This is not a “simple” task though we have a number of helper functions to do this sort of thing in the Microsoft.Uii.Csr.Win32Api assembly.

Functionally,

Assuming your automating the login, and its working properly;
You need to raise an action to your adapter when the login process completes, that action will then trigger a search for the new window, the main window of your application. Then you can use the methods in the Win32Api Assembly to get and parent the window back to the adapter.

The methods you’re going to use are these :

Microsoft.Uii.Csr.Win32Api.WindowFinder f = new Microsoft.Uii.Csr.Win32Api.WindowFinder("windowclass", "windowcaption", 100);
HandleRef winHref = f.FindWindow(iTimeOut, bDontBlock);

Microsoft.Uii.Csr.Win32Api.WindowParenter p = new Microsoft.Uii.Csr.Win32Api.WindowParenter(parentHRef, winHref, false, false);
p.UpdateChildSize();

Note, if you’re going to go live on CRM 2011, then you may want to wait for the update to UII… there are a few features added to address this type of scenario in a simpler manner.

Mattb-MSFT

Jan 18, 2011 at 4:11 PM

Hi Matt,

Thanks for your valuable iinformation.

I am pretty new to CCA. I am unable to find the way how to reacquire the new window which is mentioned in your first line.

Can you point me any doc regarding this and in general how to work with HostedApplication(for Desktop Application) in CCA?

 

Thanks in advance.

Best Regards,

Alim

Apr 20, 2011 at 12:24 PM

Hi Matt,

I tried doing it as suggested by you.. but no luck so far :(

I have one question, can we configure an external hosted application to use a WinDDA and still have an automation executed using a HAT workflow?

I am really stuck with this problem... any help is welcome.

-Nitin

Apr 21, 2011 at 2:11 PM

Yes... this can be done but its not trival coding to get it working.
Is your situation the same as above?  if not can you describe. ?

 

MattB.

Apr 25, 2011 at 6:47 AM

Hi Matt,

My situation is same, I have configured an external hosted application. i have automated the login process using SSO and HAT workflow assembly.

Once successfully logged into the application, the application opens the main window as new window.

I tried to run Spy++ to get the handles for the login window but its giving some error and is not able to find it.

My problem is to re-host the application to be displayed withing the tab (MainPanel) of ADT.

Also so, even if we write an adapter to re-host it, due to the limitations of WPF (only the main window has a handle and rest all controls are just elements without handles) how can we achieve it. It will be attached to the MainWindow and cannot be(as far as my knowledge) attached to the tab in MainPanel.

-Nitin

Apr 26, 2011 at 2:39 PM
Ok, so there are a few ways that we can make this work..
HOWEVER,
CCA for CRM 2011 is literally around the corner, and the updated HAT engine provides some updated capabilities that makes this a lot simpler to do.

My recommendation is to wait for CCA for CRM 2011 to do this... less you want to dig into win32 mechanics :)

MattB-msft.




From: [email removed]
To: [email removed]
Date: Sun, 24 Apr 2011 22:47:57 -0700
Subject: Re: External Hosted Application - Opens new window [crmcca:234684]

From: nitinakadam
Hi Matt,
My situation is same, I have configured an external hosted application. i have automated the login process using SSO and HAT workflow assembly.
Once successfully logged into the application, the application opens the main window as new window.
I tried to run Spy++ to get the handles for the login window but its giving some error and is not able to find it.
My problem is to re-host the application to be displayed withing the tab (MainPanel) of ADT.
Also so, even if we write an adapter to re-host it, due to the limitations of WPF (only the main window has a handle and rest all controls are just elements without handles) how can we achieve it. It will be attached to the MainWindow and cannot be(as far as my knowledge) attached to the tab in MainPanel.
-Nitin
Read the full discussion online.
To add a post to this discussion, reply to this email (crmcca@discussions.codeplex.com)
To start a new discussion for this project, email crmcca@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com
Aug 3, 2011 at 12:13 PM

Hi senthil.,

My situation is also same..! The application opens the main window as new window.

I want Access that new window. How it is possible..?

Any idea..? Please let me know if comes up with solution.

Thanks in advance

Lings

Aug 4, 2011 at 6:01 AM

Hi,

Here is how I resolved it...

Created a new hosted control with only one control of type "WindowsFormsHost" in it and hosted it in CCA i.e TestControl;.

Fired the Login action for the external application after completing the rendering of the MainWindow.

Implemented some timeouts, depending on the time taken by the external application to load after login.

Fired another action on TestControl  to grab the main window of the external application and coded as below : 

int nTimes = 0;
while ((IntPtr.Zero == m_handle) && nTimes < 10)
{
       System.Threading.Thread.Sleep(5000);
       EnumWindows(EnumWindowsProc, 1);
       nTimes++; 
}

System.Threading.Thread.Sleep(8000);

m_logger.Info(string.Format("handle of the chid window : {0}", m_handle.ToString()));

if ((IntPtr.Zero != m_handle)) 
{
       SetParentForMainWindow((IntPtr)0);
}

CEvents.GrabWindowCompleted(new object(), new EventArgs());

if (IntPtr.Zero != m_handle)
{               
	IntPtr handlechild = Win32API.FindWindowEx(m_handle1,  
           IntPtr.Zero, "Button", "Test");

	if (IntPtr.Zero != handlechild && null != m_uiiDesktop)
        {                   
	    m_uiiDesktop.UserDefinedCommand("Log Error",  
              "HostInPanel - " + 
              HostedControls.Properties.Resources.ResMsgString271);               
       }           

}



private void SetParentForMainWindow(IntPtr childHandle)
{
    m_logger.Info("SetParentForMainWindow Begin -->>");
    try
    {
        m_logger.Info("Set parent of application window to the test 
            user  control");

       uint style = Win32API.GetWindowLong(m_handle, 
               Win32API.WindowLongType.GWL_STYLE);
        // Eliminate the titlebar of the child window
        style &= ~(uint)Win32API.WindowStyles.WS_CAPTION; 

        style &= ~(uint)Win32API.WindowStyles.WS_SYSMENU;

        SetParent(m_handle, tb.Handle);

        SetWindowPos(m_handle, (IntPtr)0, 0, 0, 965, 
                   595, 0x0040);

        Win32API.SetWindowLong(m_handlePSCRMCMS, 
                  Win32API.WindowLongType.GWL_STYLE, style);
      }           
      catch (Exception Ex)
      {
            string str = Ex.InnerException.ToString();
       } 
  }

Hope it helps :)

 

-Nitin

Aug 4, 2011 at 6:26 AM

Hi Nitin,

Thanks for your reply. I am using  CCA r2 fro CRM 2011 version. Where i can add this code..?

Help me please..!

Lings

Aug 4, 2011 at 11:16 AM

Not sure in CCA R2, did not use it yet but I hope it should be similar.

The code which I had provided in from HostInPanel() and you should call the "Login Complete" action after giving proper timeouts so that the parent window of the external application is displayed by then.

protected override void DoAction(Microsoft.Uii.Csr.RequestActionEventArgs args)
        {
            try
            {
                switch (args.Action)
                {
                    case "Login Complete":
                        m_logger.Info("CTestUserControl -> Login Complete action is executing..");
                        HostInPanel();
                        break;
                    case "Test Login":
                        m_logger.Info("CTestUserControl -> Test Login action is executing..");
                        RunAutomation();
                        break;
                }
                base.DoAction(args);
            }
            catch (Exception Ex)
            {
                m_logger.Error("CTestUserControl : DoAction " + Ex.Message);
            }
        }

Hope it helps :)

-Nitin