Launching .NET Windows App from within InfoPath?

  • Thread starter Gustaf Liljegren
  • Start date
G

Gustaf Liljegren

I made a Windows app in C# using .NET VS 2003. It's loosely related to a
group of InfoPath forms I made, so I want to add a button on a custom
toolbar to launch this app from within InfoPath. It's just a convenience
for my users. I learned how to add the button by editing the XSF file,
but how to I launch the Windows app from that button?

Ideal would be to install this button so that it's independent of the
form loaded, because there's a lot of form templates I have to modify
otherwise (but this is not a requirement).

Gustaf
 
B

Brisk

1.add code to the click event of your button
2.instantiate your windows app
MyWindowsApp myApp = new MyWindowsApp(); // this will likely require
a 'using' reference

3. call the myApp.Show() or myApp.ShowDialog() method
 
G

Gustaf Liljegren

KjellSJ said:
Using the WScript.Shell will let you start other applications:
var WshShell = new ActiveXObject("WScript.Shell");
var oExec = WshShell.Exec("calc");

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wslrfexecmethod.asp

You will get a security warning when the script runs, and might need to make
your form run under full trust.

When I run this script from the InfoPath Script Editor, all I get is the
contents of script.js in the web browser.

I have made the button in the XSF file like this:

<xsf:toolbar name="myToolbar" caption="My Toolbar">
<xsf:button caption="My Button" icon="1" tooltip="My Tooltip"
name="MyFunction"/>
</xsf:toolbar>

First, the icon doesn't show up. I tried adding a 16x16 BMP in the
resource file from InfoPath, but writing the filename in the icon
attribute didn't help. One book suggested this is an integer, so writing
"1" there seems logical.

Secondly, nothing happens when I press the button. There seem to be no
connection between the name attribute and the MyFunction function in
script.js.

Gustaf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top