public bool RegisterWindowClass() {//此处错误,不是注册ClassEx WNDCLASSEX wc = new WNDCLASSEX(); wc.style = GetClassStyle(); wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hIcon = IntPtr.Zero; wc.lpfnWndProc = __WndProc; wc.hInstance = DuiUIManager.GetInstance(); wc.hCursor = NativeMethods.LoadCursor(IntPtr.Zero, (UINT)CursorType.IDC_ARROW); int COLOR_WINDOW = 5; wc.hbrBackground = new IntPtr(COLOR_WINDOW + 1); wc.lpszMenuName = null; wc.lpszClassName = GetWindowClassName(); ATOM ret = NativeMethods.RegisterClassEx(ref wc); Debug.Assert(Marshal.GetLastWin32Error() == ERROR_CLASS_ALREADY_EXISTS); return(Marshal.GetLastWin32Error() == ERROR_CLASS_ALREADY_EXISTS); }
public HWND Create(HWND hwndParent, LPCTSTR strName, DWORD dwStyle, DWORD dwExStyle, int x, int y, int cx, int cy, HMENU hMenu) { if (GetSuperClassName() != null && !RegisterSuperclass()) { return(IntPtr.Zero); } if (GetSuperClassName() == null && !RegisterWindowClass()) { return(IntPtr.Zero); } m_hWnd = NativeMethods.CreateWindowEx(dwExStyle, GetWindowClassName(), strName, dwStyle, x, y, cx, cy, hwndParent, hMenu, DuiUIManager.GetInstance(), m_pointer); Debug.Assert(m_hWnd != IntPtr.Zero); return(m_hWnd); }