Groups | Blog | Home
all groups > dotnet compact framework > december 2007 >

dotnet compact framework : Minimize application on startup


dbgrick
12/19/2007 7:59:02 AM
You can try getting the desktop window and then sending it to the foreground,
this effectively brings up the today screen:

SetForegroundWindow( GetDesktopWindow());

Create a timer in your Activate method for initial activation. Then on timer
event, kill the timer and call the above pInvoke methods.

you can find the pInvoke definitions on pinvoke.net. I hope this helps.

Regards,
Rick D.
Contractor

[quoted text, click to view]
Paul G. Tobey [eMVP]
12/19/2007 8:23:43 AM
Define "shortcut application" for us. I don't have a good idea of what the
operation of the application looks like. You might want to indicate what
platform you are targeting, too.

Paul T.

[quoted text, click to view]

Paul G. Tobey [eMVP]
12/19/2007 10:05:00 AM
[quoted text, click to view]

But, it's not visible to begin with, no? You want it to come up initially
invisible, but to behave differently if it's already running? If so, that
seems strange, but sending the application to the background, per Rick's
suggestion. I don't think that there's any way to have a form-based
application where the form is initially invisible (that doesn't surprise me,
as I can't figure out why you'd want it to work that way myself). It would
be possible to do this from unmanaged code where you have more direct
control over the window's state...

[quoted text, click to view]

Paul T.


ctacke/
12/19/2007 11:58:19 AM
It's a known limitation in amnaged code. Application.Run always calls SHow
on the Form passed in.

The upcoming new release of the Smart Device Framework (version 2.2, due out
before the year is over) has a provision for running without showing, but we
achieved it only through creating our own message pump and application
startup routine to prevent it from using the one in the CF. There's no
other way to do it (that we've found anyway).


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com



[quoted text, click to view]
Star
12/19/2007 4:08:05 PM
Hi all,

I have been browsing the newsgroups trying to find the way
of doing that, but unfortunately everything that I tried didn't work.

I tried placing Hide() or Visible = false in the Form_Load event.

Basically I just need to hide the application as soon as your start it.
Once is running, if you click on the shortcut application it should show up.

Is there an easy way of doing that?

Star
12/19/2007 5:38:58 PM
thanks for your help.

I tried what you suggested but the problem is I still see the form for
one second before disappears. I cannot make the timer interval smaller
because in that case doesn't work. I would need something that doesn't
show the form at all.

Here is my code:


private void FormMain_Activated(object sender, EventArgs e)
{
if (!m_bInitialized)
{
preventSleepTimer = new System.Threading.Timer(new
System.Threading.TimerCallback(PokeDeviceToKeepAwake),
null, 5000, System.Threading.Timeout.Infinite);
m_bInitialized = true;
}
}

private void PokeDeviceToKeepAwake(object extra)
{
try
{
preventSleepTimer.Dispose();
preventSleepTimer = null;


Utils.Generic.SetForegroundWindow(Utils.Generic.GetDesktopWindow());
}
catch
{

}
}


Thanks



[quoted text, click to view]
Star
12/19/2007 5:42:53 PM
[quoted text, click to view]

I mean when you click on the icon in the Program's Folder where the
shortcut of my application is located. In summary, if you call my
application again needs to be visible again.

[quoted text, click to view]

I'm using VS2005, C#, Windows Mobile 5.0 pocket PC target device,
Compact Framework 2.0, desktop Windows XP...

anything else that you need?

Thanks





[quoted text, click to view]
Star
12/19/2007 6:12:47 PM

Sorry, I think my English is not too good.

It's very simple. When you start the application it will start
minimized. If you ACTIVATE it again, it will show up. As simple as that.

My program is a GPS tracker that reads data from a GPS. If you set an
option in the configuration, the program will start minimized and
reading values from the GPS, so you don't have to worry about minimizing
manually.




[quoted text, click to view]
Star
12/20/2007 12:33:11 AM
Thanks for the information.

Regards

[quoted text, click to view]
George Leithead
12/20/2007 3:32:52 AM
[quoted text, click to view]

Star,

I too am writing my own GPS tracking application (probably like a LOT
of other people) and am interested in this also.

What I want to achieve is my application to run in the background, and
take it's settings from a config file. I then have a different UI
application that allows the user to set the configuration settings
(which includes setting when to stop and start tracking, etc.). Any
Simon Hart [MVP]
12/22/2007 9:02:00 AM
And doing that would just change the position of your window in the z-order.
It could still be shown later.

Wait for OpenNETCF 2.2 or get the older ApplicationEx class from OpenNETCF
and modify the code, this is what we done and it works great. Sometimes the
framework is too helpful for its own good! ;)
--
Simon Hart
Visual Developer - Device Application Development MVP
http://simonrhart.blogspot.com


[quoted text, click to view]
ctacke/
1/15/2008 2:11:57 PM
You have to modify the source code for Application2.Run to launch the
application without showing the Form passed into the Run command. It has
nothing to do with creating a Filter or a Windows Procedure.

SDF 2.2 will include an overload that does this and will be out soon.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com





[quoted text, click to view]

LEM
1/15/2008 3:01:34 PM
Hi Simon,


I just saw your post and since I am still trying to do this, I'm trying
what you said.

I have OpenNETCF installed but I haven't been able to find that class.
I also tried this example that I found:
http://blog.opennetcf.org/ayakhnin/PermaLink.aspx?guid=9a05b2dc-c79f-4cd8-af17-aa485fada5c7

but I get an error because 'Message' cannot be found. The rest is ok.

Do you think you can share that modification that you did so I can try
it here?

Thanks a lot.


[quoted text, click to view]
LEM
1/16/2008 6:42:58 PM

Ok, I will wait then. Thanks

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