|
-
Jun 17th, 2008, 02:04 AM
#1
Thread Starter
Addicted Member
[RESOLVED] [2005] Display already open instance
I've a product with the "Enable application framework" checked with "Make single instance application checked".
In the product I've created systray icon with popupmenu having option to hide the application form. Now if user has selected application to hide on minimize and later forgets and try to reopen the product from the shortcut or else way. Then it does nothing. And user gets no information regarding what is happening.
I wants to show the application already loaded,in case user tries to reopen the product.
Please anybody tell me how I can make application visible in normal mode when second instance of the product is tried to open.
-
Jun 17th, 2008, 02:13 AM
#2
Re: [2005] Display already open instance
You need to handle the StartupNextInstance event of the application and then show your form again from there.
-
Jun 17th, 2008, 02:21 AM
#3
Thread Starter
Addicted Member
Re: [2005] Display already open instance
Thanks jmcilhinney. But I'm unable to get the StartupNextInstance event in the event list, can you help me to get the exact name of this event. Thanks in advance.
-
Jun 17th, 2008, 02:26 AM
#4
Re: [2005] Display already open instance
The exact name is: StartupNextInstance
It's an event of the application, not the form or any of your controls. You view the application events using the View Application Events button on the very same page you checked those boxes.
-
Jun 17th, 2008, 02:37 AM
#5
Thread Starter
Addicted Member
Re: [2005] Display already open instance
I've tried the StartupNextInstance event. I started the product instance and then tried to run the product from code to start the second instance with a message in the event StartupNextInstance, no message is displayed. It seems that the selected option "Make single instance application" is causing to stop product before any of the event can occur. please can you help me what other changes are needed in the event to avoid this behaviour, so that I can handle the needed actions in the StartupNextInstance event.
-
Jun 17th, 2008, 03:02 AM
#6
Re: [2005] Display already open instance
Try this:
1. Create a new WinForms project.
2. Check the "Single instance application" box.
3. Add a Button and a TextBox to the form.
4. Set the Text property of the TextBox to "Initial".
5. Double-click the Button to create a Click event handler.
6. Add this code to the event handler:7. Open the ApplicationEvents.vb code file.
8. Create a handler for the StartupNextInstance event.
9. Add this code to the event handler:10. Select Debug -> Start Without Debugging from the main menu to start an instance of the app. Note that the TextBox contains the text "Initial".
11. Change the text in the TextBox to "New".
12. Click the Button. Note that the form is hidden but the app is still running.
13. Select Debug -> Start Without Debugging from the main menu to start a second instance of the app.
Voila! Note that the TextBox contains the text "New" rather than "Initial", which it would if it was a new form.
You might like to do this again with the Task Manager open to see that there is only one instance of your application in the process list.
-
Jun 17th, 2008, 03:55 AM
#7
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|