none
Hosting applications programmatically. RRS feed

  • Question

  • Hi,

    I will like to host applications programmatically from a user control I have created in CCF.

     

    My requirement is something like this. I am displaying a list of sites in my user control. On clicking on any of those sites, I will like to open that site in a new TAB in CCF. I should be able to close those TABS (something like a dynamic application).

     

    I believe that Microsoft.Ccf.Csr exposes few classes for hosting applications. Kindly let me know which one to use.

    It will be great if some code snippet can be shared.

     

    Note:

    1) Since these applications are hosted at runtime, these applications cannot be configured in CCF.

    2) All these are global applications. I am not using sessions in my scenario.

     

     

     

    Wednesday, March 5, 2008 3:06 PM

All replies

  • One option is to configure one hosted application just to have a tab available inside the AgentDesktop for hosting the other applications selected at runtime.

    Then, when someone selects an application in your control, you can host the selected app inside the mock hosted app created before. Supposing you have the handlers for both parent (tab) and child (selected app) windows, you host the child inside the parent with some code like this one:


    Code Snippet

    private void Attach(IntPtr parentHandler, IntPtr childHandler)
    {
        
         // Obtain the child window style
         uint style = originalStyle = Win32API.GetWindowLong(childHandler, Win32API.WindowLongType.GWL_STYLE);
         // Eliminate the window, borders and title of child window
         style = style & (~(uint)(Win32API.WindowStyles.WS_POPUP |

           Win32API.WindowStyles.WS_CAPTION | Win32API.WindowStyles.WS_THICKFRAME));
         //eliminate menu if desired

         style = style | (uint)Win32API.WindowStyles.WS_CHILD;

         Win32API.SetWindowLong(childHandler, Win32API.WindowLongType.GWL_STYLE, style);

          //Insert child window inside parent
          Win32API.SetParent(childHandler, parentHandler);

          //Adjust window size
          SetWindowSize(parentHandler, childHandler);
    }


    Wednesday, March 5, 2008 6:09 PM
  • Hi Sole,

    Thanks for the reply.

     

    In my case, the no of applications I would like to host at run time is not fixed. So the user may like to open 5 applications by selecting those apps from a list in a hosted control. Then the user may chooose to close a couple of them, by closing the TAB. So using a dummy application may not work in my scenario.

     

    Is there any way I can host a application in Agent Desktop, even if the application is not configured in the server?How does the Agent Desktop host these applications? Kindly let me know.

     

    Thursday, March 6, 2008 6:44 AM
  • Hi Debangshu,

     

    You would have to modify the code piece written in Agent desktop for doing this. Currently what CCf does is , it goes through a loop of active applications which has been assigned by the admin through the admin console and creates tabs within it to do so.

     

    What I would suggest otherwise is an extension what Sole proposed.

     

    Let all these apps be hosted constrols. ow you have 5 apps with you for e.g. A,B,C,D,E for which you have created your hosted controls.

    Lest say the user decides to run A,C and E. Now what you would do is externally run hosted control A first , once the application has been run and made a child of CCF as sole suggested byt doing setparent, run base.firerequestargs("","") where you could supply the name of the next application as per chosen and the action . based on this action the hosted control C in thsi case would run the process and do the same as done by A

     

    Graphically representing it would be like this

    A ------->                                                          C ------------------->                                                                      E

    Host application and fire "Run C"               On action "run C" host application and fire action "run E"             On action

         "Run E" host    appication E

     

    Nikhil
    Thursday, April 3, 2008 11:11 AM
  • CCF 2008 has a feature called Dynamic Applications for this purpose.
    you still need to configure the applications on the CCF server, however you can instance them and dismiss them at will.. both by user actions and software.

     

    Clarification :
    you seem to be talking about Web Application / Web Page’s .  You can use Dynamic apps to do this by building a max list of potential window placeholders in CCF’s admin console.   I have done this a few times before
    J

    For Example:
                  name: WindowBrowserN  ( where N the window number ) 
                  Type:  Web Browsers
                  Base URL: about:blank 
                  Application is Dynamic is Checked
                  Show in Tool Bar Drop Down is Unchecked
                  User Can Close Is Checked
                  use a Legacy Adapter to handed actions
                   

      Actions:
      default  - URL : about:blank
      Nav – URL : about:blank

    You use the Context to store the current Number your on

    From your root application, Use the context to notify the IAD that you want to add a new window to the env,  the IAD will sort out which Window is available and instance it with Load Dynamic App. Then the IAD will call DoAction on the newly created app, passing in an Action Type of NAV and the URL you want to to open.

    You can also do this for Win32 and Hosted controls

    This approach also works for Instanced sessions.

     

    MattB MSFT

    Wednesday, April 23, 2008 5:40 AM
    Moderator
  • Hi MattB, me again :)

    According to this article http://technet.microsoft.com/en-us/library/dd632675.aspx, dynamic applications, cannot be closed programmatically unless the "User can close the application dynamically" check box is checked.

    But i'm don't want see the red "X" at CCF TAB.

    How can i close a dynamic application programmatically? I tried using ApplicationHost.UnloadDynamicApplication(int) method, but this threw a exception: "This dynamic application has not been configured as user-closeable."

    Any idea?

    Thanks.

    Regards.

    Brian Garnica
    • Proposed as answer by Unmesh Friday, February 19, 2010 1:13 AM
    Thursday, May 7, 2009 7:21 PM
  • Could you give me a bit more of the Scenario?
    Im not sure dynamic apps would be what you want to do here..

    MattB-Msft

    Friday, May 15, 2009 10:45 PM
    Moderator