CreateWindowEx() 개인적인 메소드

private CreateWindowEx ( WS_EX dwExStyle, string lpClassName, string lpWindowName, WS dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam ) : IntPtr
dwExStyle WS_EX
lpClassName string
lpWindowName string
dwStyle WS
x int
y int
nWidth int
nHeight int
hWndParent System.IntPtr
hMenu System.IntPtr
hInstance System.IntPtr
lpParam System.IntPtr
리턴 System.IntPtr
예제 #1
0
        public MessageWindow(CS classStyle, WS style, WS_EX exStyle, Rect location, string name, WndProc callback)
        {
            // A null callback means just use DefWindowProc.
            _wndProcCallback = callback;
            _className       = "MessageWindowClass+" + Guid.NewGuid().ToString();

            var wc = new WNDCLASSEX
            {
                cbSize        = Marshal.SizeOf(typeof(WNDCLASSEX)),
                style         = classStyle,
                lpfnWndProc   = s_WndProc,
                hInstance     = NativeMethods.GetModuleHandle(null),
                hbrBackground = NativeMethods.GetStockObject(StockObject.NULL_BRUSH),
                lpszMenuName  = "",
                lpszClassName = _className,
            };

            NativeMethods.RegisterClassEx(ref wc);

            GCHandle gcHandle = default(GCHandle);

            try
            {
                gcHandle = GCHandle.Alloc(this);
                IntPtr pinnedThisPtr = (IntPtr)gcHandle;

                Handle = NativeMethods.CreateWindowEx(
                    exStyle,
                    _className,
                    name,
                    style,
                    (int)location.X,
                    (int)location.Y,
                    (int)location.Width,
                    (int)location.Height,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    pinnedThisPtr);
            }
            finally
            {
                gcHandle.Free();
            }

            _dispatcher = Dispatcher.CurrentDispatcher;
        }