all groups > dotnet compact framework > november 2006 >
You're in the

dotnet compact framework

group:

Strange Behaviour of BringToFront (OneInstance)


Strange Behaviour of BringToFront (OneInstance) Thorsten
11/27/2006 6:56:09 PM
dotnet compact framework:
Hi,

we have a (rather complex) .Net 1.0 CF application running on WindowsCE5.0
(no PPC).

To ensures that our app runs only once we use code based upon the
OneInstance sample from gotdotnet UserSamples. This seems to work fine BUT
bringing our application to the front doesn't always work:
OurApp running
ThirdPartyApp Launched
OurApp started again => bring to front has no effect => *BUG*

What Does work is:
OurApp running
ThirdPartyApp Launched
SimpleFormApp Launched
OurApp started again => bring to front works as expected !?!?!?

SimpleFormApp is really just an application with a simple form.

When using the sample apllication that comes with the OneInstance sample
everything works just fine. One difference I note is that on the sample I
see an "opening" and then a "closing" animation (growing/shrinking
rectangles) which I don't see on our application.

What is special about our main form is that it has the following settings:
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

this.ControlBox = false;

this.MaximizeBox = false;

this.MinimizeBox = false;

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

(but the OneInstance sample with the same settings works just fine, too)

Any ideas?
Thorsten

Re: Strange Behaviour of BringToFront (OneInstance) Peter Foot [MVP]
11/27/2006 8:42:30 PM
BringToFront only has effect within an application. If you want to bring the
application to the front P/Invoke SetForegroundWindow. This article
explains:-
http://www.peterfoot.net/BringANETCFFormToTheForeground.aspx

Peter

--
Peter Foot
Device Application Development MVP
www.peterfoot.net | www.inthehand.com

[quoted text, click to view]
AddThis Social Bookmark Button