public void RegisterClass(ClassCreateParams ccp) { NativeMethods.WNDCLASSEX wc = new NativeMethods.WNDCLASSEX() { cbSize = Marshal.SizeOf(typeof(NativeMethods.WNDCLASSEX)), lpszClassName = ccp.Name, lpfnWndProc = ccp.WndProc, style = (int)ccp.Style, cbClsExtra = ccp.ExtraClassBytes, cbWndExtra = ccp.ExtraWindowBytes, hbrBackground = ccp.BackgroundBrush, hInstance = Marshal.GetHINSTANCE(this.GetType().Module) }; if (NativeMethods.RegisterClassEx(ref wc) != 0) { throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error()); } }