public static void Main()
        {
            HINSTANCE instance = new HINSTANCE(Win32.GetModuleHandle(null));

            if (instance != null)
            {
                Console.WriteLine("Instance instance created");
                WndProc windowProc = new WndProc(MainCallback);

                WNDCLASS windowClass = new WNDCLASS();
                windowClass.Style = Win32.Cs.HorizontalRedraw | Win32.Cs.VerticalRedraw | Win32.Cs.OwnDC;
                windowClass.Instance(instance);
                windowClass.WindowProc = windowProc;
                windowClass.ClassName  = "AoESharpWindowClass";
                windowClass.Cursor(Win32.LoadCursor(null, (short)Win32.Idc.Arrow));
                windowClass.Background(Win32.GetStockObject(StockObject.BlackBrush));

                if (Win32.RegisterClass(ref windowClass) != 0)
                {
                    Console.WriteLine("Class registered successfully");

                    HWND window = new HWND(Win32.CreateWindowEx(0, windowClass.ClassName, "Age of Empires Sharp", Win32.Ws.OverlappedWindow,
                                                                (uint)Win32.Cw.UseDefault, (uint)Win32.Cw.UseDefault,
                                                                (uint)Win32.Cw.UseDefault, (uint)Win32.Cw.UseDefault,
                                                                null, null, instance, new IntPtr(0)));

                    if (window != null)
                    {
                        Console.WriteLine("Window created successfully");
                        WindowDim = new WindowDimension(window);
                        Win32.ShowWindow(window, (uint)Win32.Sw.Show);

                        IsRunning = true;
                        while (IsRunning)
                        {
                            ProcessPendingMessages();
                        }
                    }
                    else
                    {
                        Console.WriteLine("Win32 Error: {0}", Win32.GetLastError());
                    }
                }
                else
                {
                    Console.WriteLine("Win32 Error: {0}", Win32.GetLastError());
                }
            }
            else
            {
                Console.WriteLine("Win32 Error: {0}", Win32.GetLastError());
            }
        }
Esempio n. 2
0
 public static extern IntPtr CreateWindowExW(
     DWORD dwExStyle,
     string lpClassName,
     string lpWindowName,
     WS dwStyle,
     int X,
     int Y,
     int nWidth,
     int nHeight,
     HWND hWndParent,
     HMENU hMenu,
     HINSTANCE hInstance,
     LPVOID lpParam
     );
Esempio n. 3
0
 public static extern HCURSOR LoadCursorW(
     HINSTANCE hInstance,
     IDC lpCursorName
     );