How to catch the Minimize Event to change form.text() property

G

Guest

hi,
i have set the minimize button property of the ppc form to True. So while
minimizing the form, i wish to set the text property of the form,
form1.text()="", so that the form will not be displayed in the running
program list. So what code I have to write in the Deactivate event() to
determine whether the form is minimizing/minimized or not?
Or in which event, i have to set form1.text="" ? Since some message boxes
will be displayed in the form, the deactivate event will be called frequently.

Thanks in advance,
regards,
hari
 
S

Sergey Bogdanov

I've written small test and noticed that when a Smart Minimized button
is pressed a window doesn't change its state (window styles stay the
same, size is unchanged, etc.) except one thing - Z-Order. It seems that
a window is pushed to bottom of z-order by API call like:

SetWindowPos(wnd, HWND_BOTTOM...);

You can retrieve window siblings (and compare it with previous values)
by using GetWindow function. Also check out this thread:
http://groups.google.com/groups?hl=...soft.public.dotnet.framework.compactframework

The code below is an example how to use it together:

IntPtr _oldprev;
IntPtr _oldnext;
IntPtr GetHandle()
{
this.Capture = true;
IntPtr hwnd = GetCapture();
this.Capture = false;
return hwnd;
}

protected override void OnActivated(EventArgs e)
{
base.OnActivated (e);

this.Text = "FormTitle";

IntPtr hwnd = GetHandle();
_oldprev = GetWindow(hwnd, GW_HWNDPREV);
_oldnext = GetWindow(hwnd, GW_HWNDNEXT);
}

protected override void OnDeactivate(EventArgs e)
{
base.OnDeactivate(e);

IntPtr hwnd = GetHandle();
if (GetWindow(hwnd, GW_HWNDPREV) != _oldprev || GetWindow(hwnd,
GW_HWNDNEXT) != _oldnext)
{
this.Text = "";
}
}

const int GW_HWNDNEXT = 2;
const int GW_HWNDPREV = 3;

[DllImport("coredll")]
static extern IntPtr GetWindow(IntPtr hwnd, int cmd);

[DllImport("coredll")]
static extern IntPtr GetCapture();


Hope this help,
Sergey Bogdanov
 

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