Launch infopath form with a winform - InfoPath Dev
in

InfoPath Dev

Launch infopath form with a winform

Last post 02-05-2006 11:05 PM by Coita Thierry. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 01-24-2006 01:52 AM

    Launch infopath form with a winform

    Hi,

    I need to make a central place for my application and I asking me if there is a way for launch an xsn in a winform(c#)? I think yes but I didn't find how to make this possible.

    The model is in t:\RC\AV.xsn

    Additionnal question if the first answer is yes: in the How-to Pass parameter to infopath: http://www.infopathdev.com/howto/tutorials/default.aspx?i=af9e48a6e43c41f4be62296a7fa0e494
    It's explain how to pass a paramater as an xmlfile! The example explain how you can make this with Sharepoint. Is there a way to pass parameter as an xml File with C# or Jscript in a winform?

    Any link, explanation, tutorial, ... can be post!

    Thanks a lot!

    Thierry
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 01-30-2006 04:53 AM In reply to

    Re: Launch infopath form with a winform

    Hi,

    Nobody has an idea about how to make?

    Thanks!

    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 01-30-2006 10:11 AM In reply to

    Re: Launch infopath form with a winform

    Have never tried but do not see why it is not possible. Do you have access to the XML in .NET? You could load the xml into an XMLDocument object, make your changes and then open up the XML in InfoPath... Just brainstorming here...
    Jason
    http://www.k2distillery.com/
  • 01-31-2006 12:54 AM In reply to

    Re: Launch infopath form with a winform

    Thanks for your reply!

    Thanks for the idea that answer to my additionnal question!

    My problem is that I don't know how to launch my infopath form in my winform? How achieve this?

    Thanks

    Thierry
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 02-02-2006 07:49 PM In reply to

    Re: Launch infopath form with a winform

    Hi Thierry,
    Sorry for the delay here. You will have to do the equivalent of an AppExec command to launch InfoPath and specify the the xsn file as a parameter. It's totally possible from code.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 02-03-2006 02:20 AM In reply to

    Re: Launch infopath form with a winform

    Hi Patrick,

    I don't have find what is your AppExec but when I was searching about it but I found another way with process.start (strange I didn't found anything on who I can launch infopath and when you speak about your solution I find another ;) ):

    ProcessStartInfo processInfo = new ProcessStartInfo(@"c:\RC\affaire.xsn");
    processInfo.WindowStyle = ProcessWindowStyle.Hidden;
    Process arjProcess = new Process();
    arjProcess.StartInfo = processInfo;
    arjProcess.Start();

    Do you think it's a good idea? That works it's already a good things. Do you know the difference between this two method?

    Thanks
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
  • 02-04-2006 01:11 AM In reply to

    Re: Launch infopath form with a winform

    Yeah, I think that's worth a twirl! Sorry, my Windows and .NET API knowledge is waning... hey! you're at 285 posts ... how was that Quilceda? Want something fron France?

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 02-04-2006 09:11 AM In reply to

    Re: Launch infopath form with a winform

    You may also want to use some basic menu API functions to remove any controls or menu fuctions that you do not want the user to have access to. Below is a quick launch of infopath and handle to capture exit event. Edit the xml query fields in the xml before you launch infopath, then just supply the xml as a argument as below. Beware also that Infopath does not like to run with multiple instances, it will attempt to close any running instances thereby throwing an early exit event if there is a copy of infopath already running when you attempt to launch this process. (ie. the designer is already running and you attempt to start a new process such as that below it will immediately throw an exit code which will foul up your waiting for exit)

    Public Sub OpenInfoPathXMLviaProcess(ByVal XMLFile As String)
    Dim SI As ProcessStartInfo = New ProcessStartInfo("infopath.exe")
    Dim DWFInfoPath As New Process

    Try
    SI.ErrorDialog = True
    SI.Arguments = ("""" & XMLFile & """")
    SI.WindowStyle = ProcessWindowStyle.Normal
    DWFInfoPath.EnableRaisingEvents = True
    DWFInfoPath.StartInfo = SI

    'Add event handler for the exit event
    AddHandler DWFInfoPath.Exited, AddressOf DWFInfoPathProcessExited

    'Start
    DWFInfoPath.Start()
    DWFInfoPath.WaitForExit() 'Indefinitely waiting

    Catch ex As Exception
    'Your Error handling here
    Finally
    If DWFInfoPath.HasExited = False Then
    DWFInfoPath.Close()
    End If
    End Try
    End Sub

    Public Sub DWFInfoPathProcessExited(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim DWFInfoPathProcess As Process = DirectCast(sender, Process)
    Try
    If Not DWFInfoPathProcess Is Nothing Then
    'MessageBox.Show("The process exited, raising the Exited event at: " & _
    ' DWFInfoPathProcess.ExitTime & "." & System.Environment.NewLine & _
    ' "Exit Code: " & DWFInfoPathProcess.ExitCode)
    End if

  • 02-04-2006 09:25 AM In reply to

    Re: Launch infopath form with a winform

    There is always the interop as well, just a quick example. The unfortunate issue that I find with the interop and infopath is the lack of an exit or quit event, unlike word or excel etc. Makes it somewhat difficult to detect the exit of the application. Of course you can then use API functions such as FindWindow to grab the handle and then setup your own thread to monitor for the exit of the infopath app, but at that point just as well start infopath via a process making it easier to manage the process. But then you give up the nice little interop options to open infopath in "read only" mode etc.

    Imports objOffice = Microsoft.Office.Core
    Imports objInfoPath = Microsoft.Office.Interop.InfoPath

    Friend IPApp As objInfoPath.Application = CreateObject("InfoPath.Application")
    Friend IPDocs As objInfoPath.XDocuments = IPApp.XDocuments
    Friend WithEvents IPDoc As objInfoPath.XDocument

    Public Sub OpenInfoPathXML(ByVal XMLFile As String)
    'http://www.mcse.ms/archive180-2005-2-707067.html

    IPDoc = IPDocs.Open(XMLFile)

    IPApp.Visible = True
    IPApp.WindowState =
    End Sub


  • 02-05-2006 11:05 PM In reply to

    Re: Launch infopath form with a winform

    Hi,

    Thanks for your answer! That looks great! I will try this!

    ++

    Thierry

    P.S.Patrick, for the Quilceda I dont have drink it but it's for the next week-end! I have invite some friends at home! I'll give you some feedbacks! Sorry but this time I'm a little bit busy I have promise you one article I will try to make this this week!
    Infopath 2007, Langage: C#2.0 (Modèle Objet 2003)
    merci de lire ceci
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.