本文整理汇总了C#中POINT类的典型用法代码示例。如果您正苦于以下问题:C# POINT类的具体用法?C# POINT怎么用?C# POINT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
POINT类属于命名空间,在下文中一共展示了POINT类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:mok-aster,项目名称:NasneCapture,代码行数:25,代码来源:WIndowCapture.cs
示例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();
}
};
}
开发者ID:stefan-baumann,项目名称:MakeTopMost,代码行数:28,代码来源:Program.cs
示例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;
}
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:59,代码来源:TableColumnSizeEditor.cs
示例4: WindowFormPoint
public static IntPtr WindowFormPoint(System.Drawing.Point point)
{
var p = new POINT();
p.x = point.X;
p.y = point.Y;
return WindowFromPoint(p);
}
开发者ID:namoshika,项目名称:SnkLib.Win.Forms.DockingWindow,代码行数:8,代码来源:API_SendInput.cs
示例5: 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);
}
开发者ID:philc,项目名称:InstallPad,代码行数:8,代码来源:Interop.cs
示例6: GetWindowTextUnderCursor
public static string GetWindowTextUnderCursor()
{
POINT pointCursor = new POINT();
if (!(GetCursorPos(out pointCursor))) return string.Empty;
return GetWindowText(pointCursor);
}
开发者ID:bleissem,项目名称:automate,代码行数:8,代码来源:WindowRecorder.cs
示例7: GetCurrentMonitor
public static IntPtr GetCurrentMonitor()
{
POINT point = new POINT();
if (!GetCursorPos(out point))
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
return MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST);
}
开发者ID:alexhorn,项目名称:BrightnessControl,代码行数:9,代码来源:DisplayConfiguration.cs
示例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;
}
开发者ID:paul-green,项目名称:O2.Platform.Scripts,代码行数:12,代码来源:Win32_Helper_Methods.cs
示例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);
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:9,代码来源:User32_Window.cs
示例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);
}
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:9,代码来源:TableCellEditingElementBehavior.cs
示例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;
}
开发者ID:XtremeKevinChow,项目名称:smartwin32api,代码行数:15,代码来源:UnsafeNativeMethods.cs
示例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;
}
开发者ID:alexryassky,项目名称:actionlogger,代码行数:16,代码来源:cEnumerator.cs
示例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);
}
开发者ID:GoldRenard,项目名称:DMOAdvancedLauncher,代码行数:16,代码来源:HwndSourceExtensions.cs
示例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);
}
开发者ID:Ragnarock70,项目名称:Helper,代码行数:12,代码来源:Handler.cs
示例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);
}
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:13,代码来源:MyWindowsMouse.cs
示例16: WndOnMouseDown
void WndOnMouseDown()
{
var hwnd = FindWindow(null, "CooldogAssistant");
if (hwnd != IntPtr.Zero)
{
POINT p;
GetCursorPos(out p);
p.X -= Screen.width / 2;
p.Y -= Screen.width / 4;
DragStart = p;
Dragging = false;
}
}
开发者ID:renaudbedard,项目名称:cooldog-assistant,代码行数:15,代码来源:Draggable.cs
示例17: EqualityTest
public void EqualityTest()
{
POINT p = new POINT(20, 40);
POINT p2 = new POINT(20, 40);
Point p3 = new Point(20, 40);
Assert.AreEqual(p, p2);
Assert.AreEqual(p, p3);
Point p4 = new Point(30, 30);
POINT p5 = new POINT(50, 60);
Assert.AreNotEqual(p, p4);
Assert.AreNotEqual(p, p5);
}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:15,代码来源:PointTests.cs
示例18: SetView
public void SetView(Bitmap newView, int newOpacity)
{
if (newView == null) return;
if (newView.PixelFormat != PixelFormat.Format32bppArgb)
throw new ApplicationException("The bitmap must be 32ppp with alpha-channel.");
View = newView;
Opacity = newOpacity%256;
IntPtr screenDc = User.GetDC(IntPtr.Zero);
IntPtr memDc = GDI.CreateCompatibleDC(screenDc);
IntPtr hBitmap = IntPtr.Zero;
IntPtr oldBitmap = IntPtr.Zero;
try
{
hBitmap = newView.GetHbitmap(Color.FromArgb(0));
oldBitmap = GDI.SelectObject(memDc, hBitmap);
var size = new SIZE {cx = newView.Width, cy = newView.Height};
var pointSource = new POINT {x = 0, y = 0};
var topPos = new POINT {x = Left, y = Top};
var blend = new User.BLENDFUNCTION
{
BlendOp = User.AC_SRC_OVER,
BlendFlags = 0,
SourceConstantAlpha = (byte) newOpacity,
AlphaFormat = User.AC_SRC_ALPHA
};
User.UpdateLayeredWindow(Handle, screenDc, ref topPos,
ref size, memDc, ref pointSource,
0,
ref blend, User.ULW_ALPHA);
}
finally
{
User.ReleaseDC(IntPtr.Zero, screenDc);
if (hBitmap != IntPtr.Zero)
{
GDI.SelectObject(memDc, oldBitmap);
GDI.DeleteObject(hBitmap);
}
GDI.DeleteDC(memDc);
}
}
开发者ID:luowei98,项目名称:RobertLw,代码行数:47,代码来源:AlphaForm.cs
示例19: MouseMoveToPointInClientRect
static public void MouseMoveToPointInClientRect(
IntPtr WindowHandle,
Vektor2DInt DestinationPointInClientRect,
out POINT DestinationPointInScreen)
{
DestinationPointInScreen = DestinationPointInClientRect.AsWindowsPoint();
// get screen coordinates
BotEngine.WinApi.User32.ClientToScreen(WindowHandle, ref DestinationPointInScreen);
var lParam = (IntPtr)((((int)DestinationPointInClientRect.B) << 16) | ((int)DestinationPointInClientRect.A));
var wParam = IntPtr.Zero;
BotEngine.WinApi.User32.SetCursorPos(DestinationPointInScreen.x, DestinationPointInScreen.y);
BotEngine.WinApi.User32.SendMessage(WindowHandle, (uint)SictMessageTyp.WM_MOUSEMOVE, wParam, lParam);
}
开发者ID:trainingday01,项目名称:Optimat.EveOnline,代码行数:17,代码来源:WindowMotor.cs
示例20: SetIMEWindowLocation
public void SetIMEWindowLocation(int x, int y)
{
POINT p = new POINT();
p.x = x;
p.y = y;
COMPOSITIONFORM lParam = new COMPOSITIONFORM();
lParam.dwStyle = CFS_POINT;
lParam.ptCurrentPos = p;
lParam.rcArea = new RECT();
int i = SendMessage(
hIMEWnd,
WM_IME_CONTROL,
IMC_SETCOMPOSITIONWINDOW,
lParam
);
}
开发者ID:Whimsyduke,项目名称:GalaxyEditorPlusPlus,代码行数:18,代码来源:Ime.cs
注:本文中的POINT类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论