[Mwinapi-commits] SF.net SVN: mwinapi:[85] trunk/ManagedWinapi/SystemWindow.cs
Status: Beta
Brought to you by:
schierlm
|
From: <sch...@us...> - 2009-11-10 17:20:01
|
Revision: 85
http://mwinapi.svn.sourceforge.net/mwinapi/?rev=85&view=rev
Author: schierlm
Date: 2009-11-10 17:19:48 +0000 (Tue, 10 Nov 2009)
Log Message:
-----------
Add a SystemWindow.PostClose() method. It's basically identical to
SystemWindow.SendClose(), except it works in some situations where SendClose does
not, namely closing Windows Explorer windows. (For a complete discussion, see
<http://stackoverflow.com/questions/1694451/>)
[submitted by James Sulak <jsulak at gmail dot com>]
Modified Paths:
--------------
trunk/ManagedWinapi/SystemWindow.cs
Modified: trunk/ManagedWinapi/SystemWindow.cs
===================================================================
--- trunk/ManagedWinapi/SystemWindow.cs 2009-10-03 17:34:38 UTC (rev 84)
+++ trunk/ManagedWinapi/SystemWindow.cs 2009-11-10 17:19:48 UTC (rev 85)
@@ -1030,6 +1030,17 @@
}
/// <summary>
+ /// Post a message to this window that it should close. This is equivalent
+ /// to clicking the "X" in the upper right corner or pressing Alt+F4.
+ /// It sometimes works in instances where the <see cref="SendClose"/> function does
+ /// not (for example, Windows Explorer windows.)
+ /// </summary>
+ public void PostClose()
+ {
+ PostMessage(HWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
+ }
+
+ /// <summary>
/// Highlights the window with a red border.
/// </summary>
public void Highlight()
@@ -1310,6 +1321,9 @@
internal static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, [Out] StringBuilder lParam);
[DllImport("user32.dll")]
+ private static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport("user32.dll")]
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,
int Y, int cx, int cy, uint uFlags);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|