public EngineWindow(string name, string icon, Size size) { Name = name; Icon = icon; Size = size; mWndProc = WindowProc; LogEmitter.Apply(LogLevel.Information, "[Start Create Window] [Name = {0}] from [EngineWindow]", Name); //get instance var hInstance = APILibrary.Win32.Internal.GetModuleHandle(null); //create app info(WNDCLASS)s, default setting var appInfo = new APILibrary.Win32.AppInfo() { style = (uint)APILibrary.Win32.AppInfoStyle.CS_DBLCLKS, lpfnWndProc = mWndProc, cbClsExtra = 0, cbWndExtra = 0, hInstance = hInstance, hIcon = APILibrary.Win32.Internal.LoadImage(IntPtr.Zero, Icon, 1, 0, 0, 0x00000010), hbrBackground = APILibrary.Win32.Internal.GetStockObject(0), hCursor = APILibrary.Win32.Internal.LoadCursor(IntPtr.Zero, (uint)APILibrary.Win32.CursorType.IDC_ARROW), lpszMenuName = null, lpszClassName = Name }; //register app info(WNDCLASS) APILibrary.Win32.Internal.RegisterAppinfo(ref appInfo); APILibrary.Win32.Rect rect = new APILibrary.Win32.Rect() { top = 0, left = 0, right = Size.Width, bottom = Size.Height }; //get real rect APILibrary.Win32.Internal.AdjustWindowRect(ref rect, (uint)APILibrary.Win32.WindowStyles.WS_OVERLAPPEDWINDOW, false); //create window mHandle = APILibrary.Win32.Internal.CreateWindowEx(0, Name, Name, (uint)APILibrary.Win32.WindowStyles.WS_OVERLAPPEDWINDOW, 0x80000000, 0x80000000, rect.right - rect.left, rect.bottom - rect.top, IntPtr.Zero, IntPtr.Zero, hInstance, IntPtr.Zero); LogEmitter.Apply(LogLevel.Information, "[Finish Create Window] [Width = {0}] [Height = {1}] from [EngineWindow]", Size.Width, Size.Height); //get window rect property APILibrary.Win32.Internal.GetWindowRect(mHandle, ref rect); //set event forwarder mEventForwardInputEmitter = new EventForwardInputEmitter(this); //set position and size Position = new Point2(rect.left, rect.top); Size = new Size(rect.right - rect.left, rect.bottom - rect.top); IsExisted = true; }
static Application() { appinfo = new APILibrary.Win32.AppInfo() { style = (uint)appstyle, cbClsExtra = 0, cbWndExtra = 0, hInstance = APILibrary.Win32.Internal.GetModuleHandle(null), hbrBackground = APILibrary.Win32.Internal.GetStockObject(0), hIcon = APILibrary.Win32.Internal.LoadImage(IntPtr.Zero, appIcon, 1, 0, 0, 0x00000010), hCursor = APILibrary.Win32.Internal.LoadCursor(IntPtr.Zero, (uint)APILibrary.Win32.CursorType.IDC_ARROW), lpszMenuName = null }; }