I have tried everything I can think of to achieve this from a desirable
point of view for the lack of a simple Minimize call.
Has anyone achieved this?
I have tried the following:
Placing a Hide() call in the Activated event - Problem with this is you can
no longer activate the application via the Control Panel\Memory applet. Also
it doesn't seem to hide the actual Window, rather just the Client visable
area.
Calling the native SetWindowPos API which sets the window on the bottom of
the Z-Order. Doesn't really work properly, part of the Window is missing and
also if an exact replication of hitting the "X" minimize button was required,
placing the Window on the bottom of the Z queue will not hide it anyway, it
would simply place it under all other Windows.
I've tried a bunch of other bodgey ways each fail....
Any ideas would be great. CF 2 - SP1, Pocket PC 2003 SE onwards.
Cheers
Simon.
It looks to me like the following will do what you want (simulate the user
clicking on the X button):
SetWindowPos( this.MyhWnd, (IntPtr)1, 0, 0, 0, 0,
SetWindowPosFlags.SWP_NOMOVE );
assuming that MyhWnd is the handle to the form window and that SWP_NOMOVE is
set based on the native code header file value...
Paul T.
"Simon Hart" <srha...@yahoo.com> wrote in message
news:7D0D1ADC-C806-43EF...@microsoft.com...
It seems the Application.Run method shows the form after it starts the
message pump. This Application class is sealed so cannot be derived from.
Calling Hide() in the Activated event does not mimic the Minimize
functionality.
Simon.
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
"Simon Hart" <srha...@yahoo.com> wrote in message
news:4FF5763B-4922-4680...@microsoft.com...
Paul T.
"Simon Hart" <srha...@yahoo.com> wrote in message
news:4FF5763B-4922-4680...@microsoft.com...
Simon.
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
"Simon Hart" <srha...@yahoo.com> wrote in message
news:A23825ED-F013-4D37...@microsoft.com...
Simon.
Paul T.
"Simon Hart" <srha...@yahoo.com> wrote in message
news:F29DE1DB-BE0A-4734...@microsoft.com...
Where in you ctor are you setting it? Before or after InitializeComponent?
If it's before, then that's expected, as your InitializeComponent code is
probably setting it back to true.
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
"Simon Hart" <srha...@yahoo.com> wrote in message
news:F29DE1DB-BE0A-4734...@microsoft.com...
I am setting it after the InitializeComponent call. InitializeComponent (by
designer) doesn't set its Visible property anyway.
Simon.
What aspect of "smart minimize" is it not copying for you?
Paul T.
"Simon Hart" <srha...@yahoo.com> wrote in message
news:ECF12B6A-6E87-4D14...@microsoft.com...
Wow, look at that. I was blantantly wrong! And I did a test app and get
the same behavior. Trying to start the app with Run(myForm) by having the
Form _not_ appear is not so simple. IMHO, this is a classic case of the
framework trying to do too much for the developer and ending up screwing us.
Since I wronged you, I tried to set it right. I've tried several P/Invoke
hacks this morning and all of them are failing. I can get the Form to hide,
but the Form title still shows at the top of the screen (that's actually a
different app in PPC/WM, BTW, which is why it's doing this).
This is what I did so far:
private bool m_firstShow = true;
public Form1()
{
InitializeComponent();
this.Activated += new EventHandler(Form1_Activated);
}
void Form1_Activated(object sender, EventArgs e)
{
if (m_firstShow)
{
SetWindowPos(this.Handle, WindowPos.Bottom, 0, 0, 0, 0,
WindPosFlag.NoMove | WindPosFlag.Hide);
m_firstShow = false;
}
}
enum WindowPos
{
Top = 0,
TopMost = -1,
NoTopMost = -2,
Bottom = 1
}
[Flags]
enum WindPosFlag
{
NoSize = 0x01,
NoMove = 0x02,
NoZOrder = 0x04,
NoActivate = 0x10,
Show = 0x40,
Hide = 0x80
}
[DllImport("coredll.dll", SetLastError = true)]
private static extern IntPtr SetWindowPos(IntPtr hWnd, WindowPos
hWndInsertAfter, int X, int Y, int cx, int cy, WindPosFlag uFlags);
Adding calls to get the desktop hWnd, invalidating it and updating it don't
help. Tapping the screen _does_ get rid of the title. The next "hack" I'd
try (and this really is a hack) is to P/Invoke mouse_event to
programmatically "tap" the upper right of the screen where the minimize
button is. It's a kluge that I don't like, but for now it's all I can think
of.
The other option is to use the OpenNETCF's ApplicationEx.Run method and
modify the code so it's doesn't show your window. That's a far cleaner
solution.
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
"Simon Hart" <srha...@yahoo.com> wrote in message
news:E5EB0AE6-3422-4931...@microsoft.com...
I have modified the ApplicationEx (in 1.4) to receive another parameter and
the class uses this to determine whether to show the form or not and it works
very well.
Thanks again for your advice.
Simon.