Cannot Hide a Window

G

Guest

I am working with VS2005 to deploy a CF .NET 2.0 app that will display an
animation whenever an incoming call comes in.

In order to do this, I want to hide the default incoming call pop-up window
titled "Phone - Incoming..." (it has the menu buttons Answer/Ignore at the
bottom), and display my own animation once I get it coded, but my attempts so
far have been unsuccessful.

Here's a snippet of my code I'm working with so far:

private Microsoft.WindowsMobile.Status.SystemState incomingProperty;
....
incomingProperty = new
Microsoft.WindowsMobile.Status.SystemState(Microsoft.WindowsMobile.Status.SystemProperty.PhoneIncomingCall);
incomingProperty.Changed += new
Microsoft.WindowsMobile.Status.ChangeEventHandler(incomingProperty_Changed);
....

void incomingProperty_Changed(object sender,
Microsoft.WindowsMobile.Status.ChangeEventArgs args)
{
IntPtr incomingHandle = FindWindow(IntPtr.Zero, "Phone -
Incoming...");
lblStatus.Text = "Status: Incoming Call";
lblPhoneNumber.Text =
Microsoft.WindowsMobile.Status.SystemState.PhoneIncomingCallerNumber;
// 0x80 = Hide Window, 0x1 = No Size, 0x2 = No Move
SetWindowPos(incomingHandle, 0,0,0,0, (0x80 | 0x1 | 0x2));
}

[DllImport("CoreDll")]
public static extern IntPtr FindWindow(IntPtr classname, string
WindowName);

[DllImport("CoreDll")]
public static extern bool SetWindowPos(IntPtr hWndInsertAfter,int
x,int y,int cx,int cy,int nFlags);
....

FindWindow seems to come back with a valid window handle for the pop-up, and
the SetWindow comes back as true, but the pop-up window does not hide. Is
there anything I am missing here?
 
G

Guest

Woops, I didn't put in the right number of parameters to SetWindow, it's
working now.

[DllImport("CoreDll")]
public static extern bool SetWindowPos(int hWnd, int
hWndInsertAfter,int x,int y,int cx,int cy,uint nFlags);

public const int HWND_BOTTOM = 0x1;
public const uint SWP_NOSIZE = 0x1;
public const uint SWP_NOMOVE = 0x2;
public const uint SWP_SHOWWINDOW = 0x40;
public const uint SWP_HIDEWINDOW = 0x80;
 

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