int main(int, char *[]) { CWindow window; window.Show({800, 600}); window.DoGameLoop(); return 0; }
void HandleMessage_SetWindowAttr(CClient& client, CDeserialiser& message) { uint16_t win_id = message.ReadU16(); uint16_t attr_id = message.ReadU16(); _SysDebug("_SetWindowAttr: (Win=%i, ID=%i)", win_id, attr_id); CWindow* win = client.GetWindow(win_id); if(!win) { throw IPC::CClientFailure("_SetWindowAttr - Bad window"); } switch(attr_id) { case IPC_WINATTR_DIMENSIONS: { uint16_t new_w = message.ReadU16(); uint16_t new_h = message.ReadU16(); win->Resize(new_w, new_h); break; } case IPC_WINATTR_POSITION: { int16_t new_x = message.ReadS16(); int16_t new_y = message.ReadS16(); win->Move(new_x, new_y); break; } case IPC_WINATTR_SHOW: win->Show( message.ReadU8() != 0 ); break; case IPC_WINATTR_FLAGS: win->SetFlags( message.ReadU8() ); // TODO: U8? why so small? break; case IPC_WINATTR_TITLE: assert(!"TODO: IPC_WINATTR_TITLE"); break; default: _SysDebug("HandleMessage_SetWindowAttr - Bad attr %u", attr_id); throw IPC::CClientFailure("Bad window attr"); } }
// FUNCTION: InitInstance(HANDLE, int) BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { CWindow wnd; g_hInstance = hInstance; ReloadLangSmart(); // LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING); // LoadString(hInstance, IDS_APP_TITLE, title, MAX_LOADSTRING); UString title = LangString(IDS_APP_TITLE, 0x03000000); /* //If it is already running, then focus on the window hWnd = FindWindow(windowClass, title); if (hWnd) { SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01)); return 0; } */ WNDCLASSW wc; // wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = 0; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FAM)); // wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hCursor = ::LoadCursor(0, IDC_SIZEWE); // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU); wc.lpszClassName = kWindowClass; MyRegisterClass(&wc); // RECT rect; // GetClientRect(hWnd, &rect); DWORD style = WS_OVERLAPPEDWINDOW; // DWORD style = 0; RECT rect; bool maximized = false; int x , y, xSize, ySize; x = y = xSize = ySize = CW_USEDEFAULT; bool windowPosIsRead = ReadWindowSize(rect, maximized); if (windowPosIsRead) { // x = rect.left; // y = rect.top; xSize = rect.right - rect.left; ySize = rect.bottom - rect.top; } UINT32 numPanels, currentPanel; g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos); if (g_PanelsInfoDefined) { if (numPanels < 1 || numPanels > 2) numPanels = kNumDefaultPanels; if (currentPanel >= 2) currentPanel = 0; } else { numPanels = kNumDefaultPanels; currentPanel = 0; } g_App.NumPanels = numPanels; g_App.LastFocusedPanel = currentPanel; if (!wnd.Create(kWindowClass, title, style, x, y, xSize, ySize, NULL, NULL, hInstance, NULL)) return FALSE; g_HWND = (HWND)wnd; WINDOWPLACEMENT placement; placement.length = sizeof(placement); if (wnd.GetPlacement(&placement)) { if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW || nCmdShow == SW_SHOWDEFAULT) { if (maximized) placement.showCmd = SW_SHOWMAXIMIZED; else placement.showCmd = SW_SHOWNORMAL; } else placement.showCmd = nCmdShow; if (windowPosIsRead) placement.rcNormalPosition = rect; wnd.SetPlacement(&placement); // window.Show(nCmdShow); } else wnd.Show(nCmdShow); return TRUE; }