Hi,
I'm writing a WinForms MDI app in C# and, with the valuable assistance of
various contributors in this forum, I have successfully got it to prevent
loading multiple instances of itself by use of a mutex and, using memory
mapped files, allows the user to open more than one of its associated
filetype.
Problem I now have is as follows (app is not running initially):
1) User clicks on an associated data file.
2) Windows launches my app.
3) The app interrogates the args property, and opens the file.
4) The app is displayed to the user i.e. has focus.
5) The user returns to Windows Explorer and clicks another associated data
file.
6) Windows again (obviously!) launches my app.
7) This second instance of my app, through the mutex, realises that another
instance of itself is already running
8) This second instance of my app creates a memory-mapped file containing
the full filespec of the file the user tried to open
9) This second instance of my app shuts itself down.
10) The first instance of my app "sees" the creation of the memory-mapped
file and opens it.
However, the app still remains flashing in the Task Bar.
I've tried various combinations of:
this.Activate();
this.Focus();
this.Show();
but to no avail. What's the best way to solve this? There used to be a
ZOrder method in VB6, and several of the MS Office apps have / had an
AppActivate method. That's the sort of thing I'm looking for.
Any assistance gratefully received, as always...
Mark