|
|
YOUR FEEDBACK
|
TOP MICROSOFT .NET LINKS Windows Forms Controls
Making Windows Forms Work with Legacy Web Applications
A pattern that uses .NET 2.0 and ClickOnce
By: Guy Starbuck
Nov. 18, 2005 11:00 AM
Digg This!
Page 2 of 2
« previous page
Next, the application needs to be modified to pass the parameters along to ExampleForm. Listing 3 shows how this can be done for new instances by overriding the OnCreateMainForm() method in the base class. This method copies the command-line arguments to a local variable, creates a new ExampleForm, then calls the Activate method overload that we added in order to pass the parameters to it. If the application is already running, however, OnCreateMainForm() won't be called, so another method is required. When Windows attempts to start an application that is already running, an event named "StartupNextInstance" fires. Listing 4 is the code for a custom event handler that does essentially the same thing as the OnCreateMain-Form() override, but for a running application. Finally, Listing 5 shows the default constructor for Program, where the StartupNextInstance event handler is wired up, and where we set Program to run as one instance. If you don't set the "IsSingleInstance" property to "True," the program will launch a new form each time it is activated. This completes the demo application.
ClickOnce Configuration
Publishing the Application The next form lets you choose whether or not a start menu shortcut will be created for this application. It does not matter for our purposes here, the example will work either way. Click "Next >" to the confirmation screen, then "Finish" to publish the application to the server.
Web Application Links Now click on the first hyperlink and see what happens. ClickOnce should prompt you to download and install the application. When installation is complete, the form will open displaying the parameter values from the hyperlink If you switch back to the HTML page in the browser and click on the other hyperlink, a ClickOnce window will display briefly, checking for new updates, then the Windows Form application will gain focus and display the parameter values from the second querystring.
Conclusion However, this pattern provides a way to launch or refresh a Windows Forms application running on a user's desktop with data from a legacy Web application, something that has been extremely difficult and risky in the past. Expanding on this pattern, systems can be engineered so that complex run-time data is transmitted quickly from Web to windows, thereby integrating the applications and increasing user productivity. Resources Page 2 of 2 « previous page
MICROSOFT .NET LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
||||||||||||||||||||||||||||||||||||