コード例 #1
0
        private void CreateFakeWnd()
        {
            var wndClsEx = new WNDCLASSEX();

            wndClsEx.Init();
            wndClsEx.style         = WndClassType.CS_VREDRAW | WndClassType.CS_HREDRAW;
            wndClsEx.lpfnWndProc   = _defWndProcDelegate;
            wndClsEx.cbClsExtra    = 0;
            wndClsEx.cbWndExtra    = 0;
            wndClsEx.hInstance     = Kernel32.GetModuleHandle(null);
            wndClsEx.hIcon         = IntPtr.Zero;
            wndClsEx.hIconSm       = IntPtr.Zero;
            wndClsEx.hCursor       = IntPtr.Zero;
            wndClsEx.hbrBackground = IntPtr.Zero;
            wndClsEx.lpszClassName = _wndClassName;
            wndClsEx.lpszMenuName  = null;

            bool success = User32.RegisterClassEx(ref wndClsEx) != 0;

            Debug.Assert(success, "RegisterWndClass failed.");

            var dwExStyle = ExtendedWndStyle.WS_EX_LAYERED | ExtendedWndStyle.WS_EX_TRANSPARENT
                            | ExtendedWndStyle.WS_EX_NOACTIVATE | ExtendedWndStyle.WS_EX_LEFT;

            var dwStyle = WndStyle.WS_VISIBLE | WndStyle.WS_OVERLAPPED;

            _fakeWindowHandle = User32.CreateWindowEx(dwExStyle, _wndClassName, null, dwStyle,
                                                      this.Left, this.Top, this.GetWidth(), this.GetHeight()
                                                      , this.Handle, IntPtr.Zero, Kernel32.GetModuleHandle(null), IntPtr.Zero);

            Debug.Assert(User32.IsWindow(_fakeWindowHandle), "CreateWindowEx failed.");
        }
コード例 #2
0
ファイル: User32.cs プロジェクト: heng222/MyRepository
 public static extern short RegisterClassEx([In] ref WNDCLASSEX lpwcx);