本文整理汇总了C#中POINT类的典型用法代码示例。如果您正苦于以下问题:C# POINT类的具体用法?C# POINT怎么用?C# POINT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
POINT类属于命名空间,在下文中一共展示了POINT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWindowSize
private Dictionary<string, int> GetWindowSize(string processName)
{
IntPtr handle = IntPtr.Zero;
foreach (Process process in Process.GetProcesses())
{
if (process.MainWindowTitle.IndexOf(processName) >= 0)
{
handle = process.MainWindowHandle;
}
}
if (handle == IntPtr.Zero)
throw new WindowNotFoundException();
RECT rect = new RECT(); POINT point = new POINT();
GetClientRect(handle, out rect);
ClientToScreen(handle, out point);
var result = new Dictionary<string, int>();
result.Add("width", (int)(rect.right - rect.left));
result.Add("height", (int)(rect.bottom - rect.top));
result.Add("x", (int)point.x);
result.Add("y", (int)point.y);
return result;
}
示例2: MainAppContext
public MainAppContext()
{
NotifyIcon trayIcon = new NotifyIcon() { Icon = Properties.Resources.TopMost, Text = "MakeTopMost", Visible = true };
trayIcon.Click += (s, e) =>
{
if (this.lastMenu != null)
{
this.lastMenu.Dispose();
}
this.lastMenu = this.CreateMenu();
NativeWindow trayIconWindow = (NativeWindow)typeof(NotifyIcon).GetField("window", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(trayIcon);
POINT cursorLocation = new POINT(); NativeMethods.GetCursorPos(out cursorLocation);
SystemWindow.ForegroundWindow = new SystemWindow(trayIconWindow.Handle);
NativeMethods.TrackPopupMenuEx(new HandleRef(this.lastMenu, this.lastMenu.Handle), 72, cursorLocation.X, cursorLocation.Y, new HandleRef(trayIconWindow, trayIconWindow.Handle), IntPtr.Zero);
NativeMethods.PostMessage(new HandleRef(trayIconWindow, trayIconWindow.Handle), 0, IntPtr.Zero, IntPtr.Zero);
};
this.ThreadExit += (s, e) =>
{
trayIcon.Dispose();
if (this.lastMenu != null)
{
this.lastMenu.Dispose();
}
};
}
示例3: HandleMouseEvent
private int HandleMouseEvent(int inEvtDispId, IHTMLEventObj pIEventObj)
{
// WinLive 160252: MSHTML throws a COMException with HRESULT 0x8000FFFF (E_UNEXPECTED) when calling
// IHTMLPaintSite.TransformGlobalToLocal if the table has no height.
IHTMLElement tableElement = (IHTMLElement)_table;
if (tableElement.offsetHeight <= 0 || tableElement.offsetWidth <= 0)
{
return HRESULT.S_FALSE;
}
// compute the element local coordinates of the point
POINT clientMouseLocation = new POINT();
clientMouseLocation.x = pIEventObj.clientX;
clientMouseLocation.y = pIEventObj.clientY;
POINT localMouseLocation = new POINT();
_paintSite.TransformGlobalToLocal(clientMouseLocation, ref localMouseLocation);
// determine if the point is within our bounds
int tableWidth = tableElement.offsetWidth + 4; // extra padding for mouse handling at right edge
Rectangle elementBounds = new Rectangle(-1, -1, tableWidth, tableElement.offsetHeight + 1);
bool mouseInElement = elementBounds.Contains(localMouseLocation.x, localMouseLocation.y);
if (mouseInElement || _sizingOperation.InProgress)
{
// create args
TableColumnMouseEventArgs mouseEventArgs = new TableColumnMouseEventArgs(
new Point(clientMouseLocation.x, clientMouseLocation.y),
new Point(localMouseLocation.x, localMouseLocation.y));
// fire the event
switch (inEvtDispId)
{
case DISPID_HTMLELEMENTEVENTS2.ONMOUSEMOVE:
OnMouseMove(mouseEventArgs);
break;
case DISPID_HTMLELEMENTEVENTS2.ONMOUSEDOWN:
OnMouseDown(mouseEventArgs);
break;
case DISPID_HTMLELEMENTEVENTS2.ONMOUSEUP:
OnMouseUp(mouseEventArgs);
break;
default:
Trace.Fail("unexpected event id");
break;
}
// indicate whether we should mask the event from the editor
return mouseEventArgs.Handled ? HRESULT.S_OK : HRESULT.S_FALSE;
}
else
{
// if the mouse is not inside the element the end sizing
_sizingOperation.EndSizing();
}
// event not handled
return HRESULT.S_FALSE;
}
示例4: UpperLeftCornerOfWindow
public static System.Drawing.Point UpperLeftCornerOfWindow(IntPtr hWnd)
{
Interop.POINT p = new POINT(0, 0);
ScreenToClient(hWnd, ref p);
// Make these positive
return new Point(p.X * -1, p.Y * -1);
}
示例5: WindowFormPoint
public static IntPtr WindowFormPoint(System.Drawing.Point point)
{
var p = new POINT();
p.x = point.X;
p.y = point.Y;
return WindowFromPoint(p);
}
示例6: GetWindowTextUnderCursor
public static string GetWindowTextUnderCursor()
{
POINT pointCursor = new POINT();
if (!(GetCursorPos(out pointCursor))) return string.Empty;
return GetWindowText(pointCursor);
}
示例7: GetCurrentMonitor
public static IntPtr GetCurrentMonitor()
{
POINT point = new POINT();
if (!GetCursorPos(out point))
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
return MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST);
}
示例8: NativeScreenToClient
//********************************
//using DllImports from DLL_User32
//********************************
public static Point NativeScreenToClient(IntPtr window, Point originalPoint)
{
POINT pOINT = new POINT(originalPoint.X, originalPoint.Y);
if (ScreenToClient(window, ref pOINT))
{
return new Point(pOINT.x, pOINT.y);
}
return Point.Empty;
}
示例9: UpdateLayeredWindow
public static extern int UpdateLayeredWindow(IntPtr hWnd,
IntPtr hdcDst,
ref POINT pptDst,
ref SIZE psize,
IntPtr hdcSrc,
ref POINT pptSrc,
uint crKey,
ref BLENDFUNCTION pblend,
uint dwFlags);
示例10: TransformGlobalToLocal
public Point TransformGlobalToLocal(Point ptGlobal)
{
POINT pointLocal = new POINT();
POINT pointGlobal = new POINT();
pointGlobal.x = ptGlobal.X;
pointGlobal.y = ptGlobal.Y;
HTMLPaintSite.TransformGlobalToLocal(pointGlobal, ref pointLocal);
return new Point(pointLocal.x, pointLocal.y);
}
示例11: ClientToScreen
/// <summary>
/// Clients to screen.
/// </summary>
/// <param name="handle">A handle.</param>
/// <param name="point">A point.</param>
/// <returns></returns>
public static POINT ClientToScreen(WindowHandle handle, POINT point)
{
POINT point1 = point;
if (!ClientToScreen(handle, ref point1))
{
throw new Win32Exception();
}
return point1;
}
示例12: FindWindowAtPos
/// <summary>
/// Функция находит дочернее окно в данной точке.
/// </summary>
/// <param name="pt">Точка в абсолютных координатах</param>
/// <returns>Возвращает дескриптор окна</returns>
public IntPtr FindWindowAtPos(System.Drawing.Point pt)
{
FindedHandle = IntPtr.Zero;
POINT APIpt = new POINT();
APIpt.X = pt.X;
APIpt.Y = pt.Y;
GCHandle GCPoint = GCHandle.Alloc(APIpt);
EnumWindowsProc cbFinder = new EnumWindowsProc(FindNextLevelWindowAtPos);
EnumChildWindows(ParentHandle,FindNextLevelWindowAtPos, GCHandle.ToIntPtr(GCPoint));
return FindedHandle;
}
示例13: TransformScreenToClient
/// <summary>
/// Transform a point from "screen" coordinate space into the
/// "client" coordinate space of the window.
/// </summary>
public static Point TransformScreenToClient(this HwndSource hwndSource, Point point)
{
HWND hwnd = new HWND(hwndSource.Handle);
POINT pt = new POINT();
pt.x = (int)point.X;
pt.y = (int)point.Y;
NativeMethods.ScreenToClient(hwnd, ref pt);
return new Point(pt.x, pt.y);
}
示例14: MouseUpEventArgs
public MouseUpEventArgs(MouseButtons button, POINT pt, IntPtr hWnd)
{
Button = button;
ScreenPoint = new Point(pt.x, pt.y);
if (hWnd == IntPtr.Zero)
return;
WindowHandle = hWnd;
PInvoke.ScreenToClient(hWnd, ref pt);
WindowPoint = new Point(pt.x, pt.y);
}
示例15: SetPosition
public static void SetPosition(int x, int y)
{
POINT pt = new POINT(x, y);
if (m_windowHandle != IntPtr.Zero)
{
unsafe
{
ClientToScreen(m_windowHandle.ToPointer(), &pt);
}
}
SetCursorPos(pt.X, pt.Y);
}