PurpleSkyHoliday
PurpleSkyHoliday

Reputation: 109

Vb.Net: How can I trigger an event when a single instance program is opened again?

I've got a single instance (set up via .net) program that operates mostly from the system tray but also has a window.

Users often lose the program among their other system tray icons and believe the program isn't running, trying to open it again from the executable.

How can I detect, within my running program, that the executable is opened again? (So that I can maximize the window)

Thanks in advance.

Upvotes: 1

Views: 649

Answers (1)

PurpleSkyHoliday
PurpleSkyHoliday

Reputation: 109

Opening another copy of a single instance program will bring your form to the front by default, but when the form isn't visible, this won't have any effect.

This is what I was looking for

The MyApplication_StartupNextInstance event occurs when another instance is started. This can be used to call any additional functions you need.

In Project Properties, You can navigate to Application -> View Application Events and handle Me.StartupNextInstance from within Partial Friend Class MyApplication.

Direct all thanks to the comments.

Upvotes: 1

Related Questions