|
using System;
using System.Runtime.InteropServices;
namespace ToolTipLibrary
{
/// <summary>
/// A static class that exposes some Win32 P/Invoke methods and structures.
/// </summary>
public sealed class NativeMethods
{
public static readonly IntPtr HWND_TOPMOST;
public const int WS_POPUP = -2147483648;
/// <summary>
/// Initializes static read-only members
/// </summary>
static NativeMethods()
{
HWND_TOPMOST = new IntPtr(-1);
}
/// <summary>
/// Private constructor prevents this class from being created.
/// </summary>
private NativeMethods()
{
}
/// <summary>
/// Win32 TOOLINFO structure.
/// </summary>
public struct TOOLINFO
{
public TOOLINFO(int flags)
{
this.cbSize = Marshal.SizeOf(typeof(TOOLINFO));
this.flags = flags;
hwnd = IntPtr.Zero;
uId = IntPtr.Zero;
rect = new RECT(0, 0, 0, 0);
hinst = IntPtr.Zero;
text = "";
lparam = IntPtr.Zero;
}
public int cbSize;
public int flags;
public IntPtr hwnd;
public IntPtr uId;
public NativeMethods.RECT rect;
public IntPtr hinst;
[MarshalAs(UnmanagedType.LPTStr)]
public string text;
public IntPtr lparam;
}
/// <summary>
/// Win32 RECT structure for use with the TOOLINFO struct above.
/// </summary>
public struct RECT
{
public RECT(int left, int top, int right, int bottom)
{
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
public RECT(System.Drawing.Point topLeft, System.Drawing.Size size)
{
this.left = topLeft.X;
this.top = topLeft.Y;
this.right = topLeft.X + size.Width;
this.bottom = topLeft.Y + size.Height;
}
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32")]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
int x, int y, int cx, int cy, int flags);
[DllImport("user32")]
public static extern IntPtr SendMessage(
IntPtr hWnd,
int Msg,
int wParam,
ref TOOLINFO lParam
);
[DllImport("user32")]
public static extern IntPtr SendMessage(
IntPtr hWnd,
int Msg,
int wParam,
int lParam);
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've been a software engineer since 1999. I tend to focus on C# and .NET technologies when possible.