Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / September 2007

Tip: Looking for answers? Try searching our database.

Detecting activation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 27 Sep 2007 19:54 GMT
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!

--
David
dbgrick - 28 Sep 2007 14:35 GMT
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

> If the user taps an icon while the application is already running, CE (or
> CF?) activates the already-running instance.
[quoted text clipped - 7 lines]
> --
> David
David - 28 Sep 2007 16:16 GMT
> 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.

--
David
<ctacke/> - 28 Sep 2007 16:52 GMT
> 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.

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.