[Mwinapi-commits] SF.net SVN: mwinapi: [62] trunk/ManagedWinapi
Status: Beta
Brought to you by:
schierlm
|
From: <sch...@us...> - 2008-03-25 22:39:01
|
Revision: 62
http://mwinapi.svn.sourceforge.net/mwinapi/?rev=62&view=rev
Author: schierlm
Date: 2008-03-25 15:38:59 -0700 (Tue, 25 Mar 2008)
Log Message:
-----------
Set default event for ClipboardNotifier, Crosshair and Hotkey,
Add properties Location and Size and methods IsValid and SendClose to SystemWindow.
[suggested by Frank Koch]
Modified Paths:
--------------
trunk/ManagedWinapi/ClipboardNotifier.cs
trunk/ManagedWinapi/Crosshair.cs
trunk/ManagedWinapi/Hotkey.cs
trunk/ManagedWinapi/SystemWindow.cs
Modified: trunk/ManagedWinapi/ClipboardNotifier.cs
===================================================================
--- trunk/ManagedWinapi/ClipboardNotifier.cs 2008-03-04 19:47:03 UTC (rev 61)
+++ trunk/ManagedWinapi/ClipboardNotifier.cs 2008-03-25 22:38:59 UTC (rev 62)
@@ -31,6 +31,7 @@
/// <summary>
/// Specifies a component that monitors the system clipboard for changes.
/// </summary>
+ [DefaultEvent("ClipboardChanged")]
public class ClipboardNotifier : Component
{
Modified: trunk/ManagedWinapi/Crosshair.cs
===================================================================
--- trunk/ManagedWinapi/Crosshair.cs 2008-03-04 19:47:03 UTC (rev 61)
+++ trunk/ManagedWinapi/Crosshair.cs 2008-03-25 22:38:59 UTC (rev 62)
@@ -14,6 +14,7 @@
/// on screen. This is useful to select other programs by dragging the crosshair
/// to a program window.
/// </summary>
+ [DefaultEvent("CrosshairDragged")]
public partial class Crosshair : UserControl
{
Image myImage;
Modified: trunk/ManagedWinapi/Hotkey.cs
===================================================================
--- trunk/ManagedWinapi/Hotkey.cs 2008-03-04 19:47:03 UTC (rev 61)
+++ trunk/ManagedWinapi/Hotkey.cs 2008-03-25 22:38:59 UTC (rev 62)
@@ -31,6 +31,7 @@
/// <summary>
/// Specifies a component that creates a global keyboard hotkey.
/// </summary>
+ [DefaultEvent("HotkeyPressed")]
public class Hotkey : Component
{
Modified: trunk/ManagedWinapi/SystemWindow.cs
===================================================================
--- trunk/ManagedWinapi/SystemWindow.cs 2008-03-04 19:47:03 UTC (rev 61)
+++ trunk/ManagedWinapi/SystemWindow.cs 2008-03-25 22:38:59 UTC (rev 62)
@@ -680,6 +680,50 @@
}
/// <summary>
+ /// The window's location inside its parent or on the screen.
+ /// </summary>
+ public Point Location
+ {
+ get
+ {
+ return Position.Location;
+ }
+
+ set
+ {
+ WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
+ wp.length = Marshal.SizeOf(wp);
+ GetWindowPlacement(_hwnd, ref wp);
+ wp.rcNormalPosition.Bottom = value.X + wp.rcNormalPosition.Height;
+ wp.rcNormalPosition.Right = value.Y + wp.rcNormalPosition.Width;
+ wp.rcNormalPosition.Top = value.X;
+ wp.rcNormalPosition.Left = value.Y;
+ SetWindowPlacement(_hwnd, ref wp);
+ }
+ }
+
+ /// <summary>
+ /// The window's size.
+ /// </summary>
+ public Size Size
+ {
+ get
+ {
+ return Position.Size;
+ }
+
+ set
+ {
+ WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
+ wp.length = Marshal.SizeOf(wp);
+ GetWindowPlacement(_hwnd, ref wp);
+ wp.rcNormalPosition.Right = wp.rcNormalPosition.Left + value.Width;
+ wp.rcNormalPosition.Bottom = wp.rcNormalPosition.Top + value.Height;
+ SetWindowPlacement(_hwnd, ref wp);
+ }
+ }
+
+ /// <summary>
/// The window's position in absolute screen coordinates. Use
/// <see cref="Position"/> if you want to use the relative position.
/// </summary>
@@ -942,6 +986,25 @@
}
}
+ /// <summary>
+ /// Whether this SystemWindow represents a valid window that existed
+ /// when this SystemWindow instance was created. To check if a window
+ /// still exists, better check its <see cref="ClassName"/> property.
+ /// </summary>
+ public bool IsValid()
+ {
+ return _hwnd != IntPtr.Zero;
+ }
+
+ /// <summary>
+ /// Send 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.
+ /// </summary>
+ public void SendClose()
+ {
+ SendSetMessage(WM_CLOSE, 0);
+ }
+
internal int SendGetMessage(uint message)
{
return SendGetMessage(message, 0);
@@ -1202,6 +1265,8 @@
[DllImport("user32.dll")]
static extern IntPtr GetDC(IntPtr hWnd);
+ private const int WM_CLOSE = 16;
+
private enum GetWindow_Cmd
{
GW_HWNDFIRST = 0,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|