public MessageWindow(Standard.CS classStyle, Standard.WS style, Standard.WS_EX exStyle, Rect location, string name, Standard.WndProc callback) { this._wndProcCallback = callback; this._className = "MessageWindowClass+" + Guid.NewGuid().ToString(); Standard.WNDCLASSEX lpwcx = new Standard.WNDCLASSEX { cbSize = Marshal.SizeOf(typeof(Standard.WNDCLASSEX)), style = classStyle, lpfnWndProc = s_WndProc, hInstance = Standard.NativeMethods.GetModuleHandle(null), hbrBackground = Standard.NativeMethods.GetStockObject(Standard.StockObject.NULL_BRUSH), lpszMenuName = "", lpszClassName = this._className }; Standard.NativeMethods.RegisterClassEx(ref lpwcx); GCHandle handle = new GCHandle(); try { handle = GCHandle.Alloc(this); IntPtr lpParam = (IntPtr)handle; this.Handle = Standard.NativeMethods.CreateWindowEx(exStyle, this._className, name, style, (int)location.X, (int)location.Y, (int)location.Width, (int)location.Height, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, lpParam); } finally { handle.Free(); } }
public static IntPtr CreateWindowEx(Standard.WS_EX dwExStyle, string lpClassName, string lpWindowName, Standard.WS dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam) { IntPtr ptr = _CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); if (IntPtr.Zero == ptr) { Standard.HRESULT.ThrowLastError(); } return(ptr); }
private static extern IntPtr _CreateWindowEx(Standard.WS_EX dwExStyle, [MarshalAs(UnmanagedType.LPWStr)] string lpClassName, [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, Standard.WS dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
public static Standard.RECT AdjustWindowRectEx(Standard.RECT lpRect, Standard.WS dwStyle, bool bMenu, Standard.WS_EX dwExStyle) { if (!_AdjustWindowRectEx(ref lpRect, dwStyle, bMenu, dwExStyle)) { Standard.HRESULT.ThrowLastError(); } return(lpRect); }
private static extern bool _AdjustWindowRectEx(ref Standard.RECT lpRect, Standard.WS dwStyle, [MarshalAs(UnmanagedType.Bool)] bool bMenu, Standard.WS_EX dwExStyle);