📄 windowhelper.cs
字号:
//==========================================================================================
//
// OpenNETCF.Win32.Win32Window
// Copyright (c) 2003-2004, OpenNETCF.org
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the OpenNETCF.org Shared Source License.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the OpenNETCF.org Shared Source License
// for more details.
//
// You should have received a copy of the OpenNETCF.org Shared Source License
// along with this library; if not, email licensing@opennetcf.org to request a copy.
//
// If you wish to contact the OpenNETCF Advisory Board to discuss licensing, please
// email licensing@opennetcf.org.
//
// For general enquiries, email enquiries@opennetcf.org or visit our website at:
// http://www.opennetcf.org
//
//==========================================================================================
using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace OpenNETCF.Win32
{
/// <summary>
/// A helper class for working with native windows.
/// </summary>
public class Win32Window
{
//native window handle
IntPtr hWnd;
private Win32Window()
{
}
private Win32Window(IntPtr hWnd)
{
this.hWnd = hWnd;
}
public static Win32Window FromControl(Control c)
{
c.Capture = true;
IntPtr hWnd = GetCapture();
c.Capture = false;
if ( hWnd == IntPtr.Zero )
throw new Exception("Unable to capture window");
return new Win32Window(hWnd);
}
static public implicit operator IntPtr(Win32Window wnd)
{
return wnd.hWnd;
}
/// <summary>
///
/// </summary>
public enum GetWindowParam: int
{
/// <summary>
///
/// </summary>
GW_HWNDFIRST = 0,
/// <summary>
///
/// </summary>
GW_HWNDLAST = 1,
/// <summary>
///
/// </summary>
GW_HWNDNEXT = 2,
/// <summary>
///
/// </summary>
GW_HWNDPREV = 3,
/// <summary>
///
/// </summary>
GW_OWNER = 4,
/// <summary>
///
/// </summary>
GW_CHILD = 5,
}
/// <summary>
///
/// </summary>
public enum GetWindowLongParam
{
/// <summary>
///
/// </summary>
GWL_WNDPROC = (-4),
/// <summary>
///
/// </summary>
GWL_HINSTANCE = (-6),
/// <summary>
///
/// </summary>
GWL_HWNDPARENT= (-8),
/// <summary>
///
/// </summary>
GWL_STYLE = (-16),
/// <summary>
///
/// </summary>
GWL_EXSTYLE = (-20),
/// <summary>
///
/// </summary>
GWL_USERDATA = (-21),
/// <summary>
///
/// </summary>
GWL_ID = (-12),
}
#region Window Styles
/// <summary>
/// Specifies the extended style of the window. This parameter can be one of the values
/// </summary>
public enum WindowStyleExtended
{
/// <summary>
/// Specifies that a window created with this style accepts drag-drop files.
/// </summary>
WS_EX_ACCEPTFILES,
/// <summary>
/// Forces a top-level window onto the taskbar when the window is visible.
/// </summary>
WS_EX_APPWINDOW,
/// <summary>
/// Specifies that a window has a border with a sunken edge.
/// </summary>
WS_EX_CLIENTEDGE = 0x00000200,
/// <summary>
/// Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter.
/// </summary>
WS_EX_DLGMODALFRAME = 0x00000001,
/// <summary>
/// Creates a window that has generic "left-aligned" properties. This is the default.
/// </summary>
WS_EX_LEFT = 0,
/// <summary>
/// If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored.
/// </summary>
WS_EX_LEFTSCROLLBAR = 0x00004000,
/// <summary>
/// The window text is displayed using left-to-right reading-order properties. This is the default.
/// </summary>
WS_EX_LTRREADING = 0,
/// <summary>
/// Creates an MDI child window.
/// </summary>
WS_EX_MDICHILD = 0x00000040,
/// <summary>
/// A top-level window created with this style cannot be activated. If a child window has this style, tapping it does not cause its top-level parent to be activated. A window that has this style receives stylus events, but neither it nor its child windows can get the focus. Supported in Windows CE versions 2.0 and later.
/// </summary>
WS_EX_NOACTIVATE = 0x08000000,
/// <summary>
/// A window created with this style does not show animated exploding and imploding rectangles, and does not have a button on the taskbar. Supported in Windows CE versions 2.0 and later.
/// </summary>
WS_EX_NOANIMATION = 0x04000000,
/// <summary>
/// Specifies that a child window created with this style does not send the WM_PARENTNOTIFY message to its parent window when it is created or destroyed.
/// </summary>
WS_EX_NOPARENTNOTIFY = 0x00000004,
/// <summary>
/// Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles.
/// </summary>
WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
/// <summary>
/// Combines the WS_EX_WINDOWEDGE, WS_EX_TOOLWINDOW, and WS_EX_TOPMOST styles.
/// </summary>
WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
/// <summary>
/// The window has generic "right-aligned" properties. This depends on the window class. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading-order alignment; otherwise, the style is ignored.
/// </summary>
WS_EX_RIGHT = 0x00001000,
/// <summary>
/// Vertical scroll bar (if present) is to the right of the client area. This is the default.
/// </summary>
WS_EX_RIGHTSCROLLBAR = 0, // Cannot find value in header file.
/// <summary>
/// If the shell language is Hebrew, Arabic, or another language that supports reading-order alignment, the window text is displayed using right-to-left reading-order properties. For other languages, the style is ignored.
/// </summary>
WS_EX_RTLREADING = 0x00002000,
/// <summary>
/// Creates a window with a three-dimensional border style intended to be used for items that do not accept user input.
/// </summary>
WS_EX_STATICEDGE = 0x00020000,
/// <summary>
/// Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE.
/// </summary>
WS_EX_TOOLWINDOW = 0x00000080,
/// <summary>
/// Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function.
/// </summary>
WS_EX_TOPMOST = 0x00000008,
/// <summary>
/// Specifies that a window created with this style should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted. To achieve transparency without these restrictions, use the SetWindowRgn function.
/// </summary>
WS_EX_TRANSPARENT = 0x00000020,
/// <summary>
/// Specifies that a window has a border with a raised edge.
/// </summary>
WS_EX_WINDOWEDGE = 0x00000100,
/// <summary>
/// Additional value for Completeness
/// </summary>
WS_EX_NONE = 0x00000000
}
//General
public enum WindowStyle : int
{
/// <summary>
/// Creates a window that has a thin-line border.
/// </summary>
WS_BORDER = 0x00800000,
/// <summary>
/// Creates a window that has a title bar (includes the WS_BORDER style).
/// </summary>
WS_CAPTION = 0x00C00000,
/// <summary>
/// Creates a child window. This style cannot be used with the WS_POPUP style.
/// </summary>
WS_CHILD = 0x40000000,
/// <summary>
/// Same as the WS_CHILD style.
/// </summary>
WS_CHILDWINDOW = 0x40000000,
/// <summary>
/// Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window.
/// </summary>
WS_CLIPSIBLINGS = 0x04000000,
/// <summary>
/// Creates a window that is initially disabled. A disabled window cannot receive input from the user.
/// </summary>
WS_DISABLED = 0x08000000,
/// <summary>
/// Creates a window that has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar.
/// </summary>
WS_DLGFRAME = 0x00400000,
/// <summary>
/// Specifies the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style. The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys.
/// </summary>
WS_GROUP = 0x00020000,
/// <summary>
/// Creates a window that has a horizontal scroll bar.
/// </summary>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -