本文整理汇总了C#中RECT类的典型用法代码示例。如果您正苦于以下问题:C# RECT类的具体用法?C# RECT怎么用?C# RECT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RECT类属于命名空间,在下文中一共展示了RECT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWindowRectangle
public static RECT GetWindowRectangle(IntPtr windowHandle)
{
RECT ret = new RECT();
GetWindowRect(windowHandle, out ret);
return ret;
}
示例2: UIWindow
protected UIWindow(string title, RECT frame)
{
fTitle = title;
fFrame = frame;
fBounds = new RECT(0, 0, frame.Width, frame.Height);
fSurfaceID = MetaSpace.CreateSurface(title, frame, new OnSurfaceCreatedEventHandler(OnSurfaceCreated));
}
示例3: TmrCursor_Tick
private static void TmrCursor_Tick(object sender, EventArgs e)
{
try {
Process[] processes = Process.GetProcesses();
foreach (var p in processes)
{
if (p.ProcessName == "devenv" || p.ProcessName == "notepad") {
Point pos = Cursor.Position;
IntPtr handle = p.MainWindowHandle;
var rectangle = new RECT();
if (!GetWindowRect(handle, ref rectangle)) continue;
var rnd = new Random();
Cursor.Position = new Point(rnd.Next(0, rectangle.Width), rnd.Next(0, rectangle.Height));
mouse_event(MouseeventfLeftdown | MouseeventfLeftup, Cursor.Position.X, Cursor.Position.Y, 0, 0);
Cursor.Position = pos;
}
}
}
catch {
// ignored
}
}
示例4: GradientRect
public GradientRect(int left, int top, int width, int height, Colorref startColor, Colorref endColor, GradientRectDirection style)
{
fRect = new RECT(left, top, width, height);
fVertices = new TRIVERTEX[2];
fGradientRect = new GRADIENT_RECT[1];
fGradientRect[0] = new GRADIENT_RECT();
SetVertices(left, top, width, height);
// Set Colors for left/top
fVertices[0].Red = startColor.Red16;
fVertices[0].Green = startColor.Green16;
fVertices[0].Blue = startColor.Blue16;
fVertices[0].Alpha = 0x0000;
// Set Colors for right/bottom
fVertices[1].Red = endColor.Red16;
fVertices[1].Green = endColor.Green16;
fVertices[1].Blue = endColor.Blue16;
fVertices[1].Alpha = 0x0000;
fGradientRect[0].UpperLeft = 0;
fGradientRect[0].LowerRight = 1;
fGradientDirection = style;
}
示例5: SyncWindowSize
private void SyncWindowSize(bool log)
{
try
{
RECT rect = new RECT();
NativeWindowMethods.GetWindowRect(_windowHandle, ref rect);
var width = rect.Right - rect.Left;
var height = rect.Bottom - rect.Top;
if (log)
{
_logger.Info("SyncWindowSize Top={0} Left={1} Width={2} Height={3}", rect.Top, rect.Left, width, height);
}
_form.InvokeIfRequired(() =>
{
if (_form.WindowState == FormWindowState.Normal)
{
_form.Top = rect.Top;
_form.Left = rect.Left;
_form.Width = rect.Right - rect.Left;
_form.Height = rect.Bottom - rect.Top;
}
});
}
catch (Exception ex)
{
_logger.ErrorException("Error syncing window positions", ex);
}
}
示例6: CaptureWindow
public static Image CaptureWindow(IntPtr handle)
{
IntPtr hdcSrc = User32.GetWindowDC(handle);
RECT windowRect = new RECT();
User32.GetWindowRect(handle, ref windowRect);
int width = windowRect.right - windowRect.left;
int height = windowRect.bottom - windowRect.top;
IntPtr hdcDest = Gdi32.CreateCompatibleDC(hdcSrc);
IntPtr hBitmap = Gdi32.CreateCompatibleBitmap(hdcSrc, width, height);
IntPtr hOld = Gdi32.SelectObject(hdcDest, hBitmap);
Gdi32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, SRCCOPY);
Gdi32.SelectObject(hdcDest, hOld);
Gdi32.DeleteDC(hdcDest);
User32.ReleaseDC(handle, hdcSrc);
Image image = Image.FromHbitmap(hBitmap);
Gdi32.DeleteObject(hBitmap);
return image;
}
示例7: GetBandRect
public Rectangle GetBandRect(int bandIndex)
{
RECT rect = new RECT();
//int index = GetBandActualIndex(bandIndex);
WindowsAPI.SendMessage(Handle, (int)RebarMessages.RB_GETRECT, bandIndex, ref rect);
return new Rectangle(rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top);
}
示例8: Capture
public static Bitmap Capture(RECT rect)
{
int width = rect.Right - rect.Left;
int height = rect.Bottom - rect.Top;
try
{
var bitmap = new Bitmap(width, height);
Graphics g = Graphics.FromImage(bitmap);
g.CopyFromScreen(new Point(rect.Left, rect.Top), new Point(0, 0),
new Size(width, height));
IntPtr dc = g.GetHdc();
g.ReleaseHdc(dc);
// bitmap.Save(Path + "\\" + GenerateFileName() + ".png", ImageFormat.Png);
//Console.WriteLine("Captured");
//g.Clear(Color.Transparent);
return bitmap;
}
catch (Exception)
{
return null;
}
}
示例9: CheckBounds
/// <summary>
///
/// </summary>
/// <param name="hWnd">被覆盖控件句柄。</param>
internal void CheckBounds(IntPtr hWnd)
{
RECT controlRect = new RECT();
RECT maskRect = new RECT();
NativeMethods.GetWindowRect(base.Handle, ref maskRect);
NativeMethods.GetWindowRect(hWnd, ref controlRect);
uint uFlag =
SWP.SWP_NOACTIVATE |
SWP.SWP_NOOWNERZORDER |
SWP.SWP_NOZORDER;
if (!NativeMethods.EqualRect(ref controlRect, ref maskRect))
{
Point point = new Point(controlRect.Left, controlRect.Top);
IntPtr hParent = NativeMethods.GetParent(base.Handle);
NativeMethods.ScreenToClient(hParent, ref point);
NativeMethods.SetWindowPos(
base.Handle,
IntPtr.Zero,
point.X,
point.Y,
controlRect.Right - controlRect.Left,
controlRect.Bottom - controlRect.Top,
uFlag);
}
}
示例10: RemoveBorder
public static void RemoveBorder(IntPtr hwnd)
{
const int SWP_FRAMECHANGED = 0x0020;
const int GWL_STYLE = -16;
const int GWL_EXSTYLE = -20;
const int WS_SYSMENU = 524288;
const int WS_THICKFRAME = 262144;
const int WS_MINIMIZE = 536870912;
const int WS_MAXIMIZE = 16777216;
const int WS_BORDER = 8388608;
const int WS_DLGFRAME = 4194304;
const int WS_CAPTION = WS_BORDER | WS_DLGFRAME;
const int WS_EX_DLGMODALFRAME = 1;
const int WS_EX_CLIENTEDGE = 512;
const int WS_EX_STATICEDGE = 131072;
var style = GetWindowLong(hwnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
SetWindowLong(hwnd, GWL_STYLE, style);
var exst = GetWindowLong(hwnd, GWL_EXSTYLE) & ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
SetWindowLong(hwnd, GWL_EXSTYLE, exst);
var rect = new RECT();
var ok = GetWindowRect(hwnd, out rect)
&& SetWindowPos(hwnd, 0, rect.X, rect.Y, rect.Width, rect.Height, SWP_FRAMECHANGED);
if (!ok)
throw new Exception("Error, can't remove border apparently.");
}
示例11: CreateSurface
public static UISurface CreateSurface(string title, RECT frame, Guid uniqueID)
{
UISurface newSurface = new UISurface(title, frame, uniqueID);
newSurface.ClearToColor(RGBColor.LtGray);
return newSurface;
}
示例12: FindWindow
/// <summary>
/// 根据窗口标题获取窗口的大小和位置(当多个标题相同的窗体存在时,默认获取上一个活动的窗体)
/// </summary>
/// <param name="WindowTitle">窗口标题(字符串不能有任何差别)</param>
/// <returns>窗口的大小和位置(System.Drawing.Rectangle)</returns>
public static System.Drawing.Rectangle FindWindow(string WindowTitle)
{
RECT rect = new RECT();
string lpClassName = null;
GetWindowRect(FindWindow(lpClassName, WindowTitle), ref rect);
return new System.Drawing.Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);
}
示例13: GradientRect
public GradientRect(int left, int top, int width, int height, uint startColor, uint endColor, GradientRectDirection style)
{
fRect = new RECT(left, top, width, height);
fVertices = new TRIVERTEX[2];
fGradientRect = new GRADIENT_RECT[1];
fGradientRect[0] = new GRADIENT_RECT();
SetVertices(left, top, width, height);
// Set Colors for left/top
fVertices[0].Red = (ushort)(RGBColor.R(startColor) << 8);
fVertices[0].Green = (ushort)(RGBColor.G(startColor) << 8);
fVertices[0].Blue = (ushort)(RGBColor.B(startColor) << 8);
fVertices[0].Alpha = 0x0000;
// Set Colors for right/bottom
fVertices[1].Red = (ushort)(RGBColor.R(endColor) << 8);
fVertices[1].Green = (ushort)(RGBColor.G(endColor) << 8);
fVertices[1].Blue = (ushort)(RGBColor.B(endColor) << 8);
fVertices[1].Alpha = 0x0000;
fGradientRect[0].UpperLeft = 0;
fGradientRect[0].LowerRight = 1;
fGradientDirection = style;
}
示例14: Pencil
public Pencil(uint colorref)
{
fColor = colorref;
//fPen = new Pen(Guid.NewGuid(), colorref, PenStyle.Solid, PenType.Cosmetic, PenJoinStyle.Round, PenEndCap.Round, 1);
fPen = new CosmeticPen(PenStyle.Solid, fColor, Guid.NewGuid());
fDrawingBounds = RECT.Empty;
}
示例15: PrintWindow
public static Bitmap PrintWindow(IntPtr hwnd)
{
RECT rc = new RECT();
User32.GetWindowRect(hwnd, ref rc);
Bitmap bmp = new Bitmap(rc.Width, rc.Height, PixelFormat.Format32bppArgb);
Graphics gfxBmp = Graphics.FromImage(bmp);
IntPtr hdcBitmap = gfxBmp.GetHdc();
bool succeeded = User32.PrintWindow(hwnd, hdcBitmap, 0);
gfxBmp.ReleaseHdc(hdcBitmap);
if (!succeeded)
{
gfxBmp.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(Point.Empty, bmp.Size));
}
IntPtr hRgn = Gdi32.CreateRectRgn(0, 0, 0, 0);
User32.GetWindowRgn(hwnd, hRgn);
Region region = Region.FromHrgn(hRgn);
if (!region.IsEmpty(gfxBmp))
{
gfxBmp.ExcludeClip(region);
gfxBmp.Clear(Color.Transparent);
}
gfxBmp.Dispose();
return bmp;
}