Detecting activation

G

Guest

If the user taps an icon while the application is already running, CE (or
CF?) activates the already-running instance.

Has anyone found a way to detect that this has happened? I need my
already-running application to do some extra UI in this case. All I'm seeing
is a call to OnActivated in my top window.

TIA!
 
G

Guest

Your WinMain method detects the presence of the application and either starts
a new instance or activates the current instance. You could place additional
code in the application activation method to send a message to your
application that this event occured. The IDE creates a method called
InitInstance in a C++ project. You could place your code in the section
where SetForegroundWindow is called. In C# you have to determine if you app
is running and then activate it or maximize it yourself. You would do this
in the Main method.

Regards,
Rick D.
Contractor
 
G

Guest

dbgrick said:
In C# you have to determine if you app
is running and then activate it or maximize it yourself. You would do this
in the Main method.

I'm not seeing this. When I attempt to launch my application a second time,
the already-running instance is brought to the foreground. No calls are made
to Main.

I understand that if you re-launch an application before the first instance
is up and running, you can get a second instance (which means you have to
supply mutex code); however, that's not the case here. The OS or CF seems to
be bringing the already-running instance to the foreground.
 
G

Guest

I'm not seeing this. When I attempt to launch my application a second
time,
the already-running instance is brought to the foreground. No calls are
made
to Main.

That is correct. I consider it a major problem with the CF implementation
in WM (CE doesn't have this problem), but that's just me. To get it to
behave, you have to rename the class of the parked form that the CF is
looking for and handle the second instance manually. Alex Feinman posted
about how to do this way back in CF 1.0 days. I believe the class name
changed in CF 2.0, but the general idea is the same.
I understand that if you re-launch an application before the first
instance
is up and running, you can get a second instance (which means you have to
supply mutex code); however, that's not the case here. The OS or CF seems
to
be bringing the already-running instance to the foreground.

It's the CF - not the OS. And the fact that you can still get a second
instance is proof that the idea of what they were trying to achieve is
broken.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 

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