static Bool winGetWorkArea (RECT *prcWorkArea, winScreenInfo *pScreenInfo) { int iPrimaryWidth, iPrimaryHeight; int iWidth, iHeight; int iLeft, iTop; int iPrimaryNonWorkAreaWidth, iPrimaryNonWorkAreaHeight; /* SPI_GETWORKAREA only gets the work area of the primary screen. */ SystemParametersInfo (SPI_GETWORKAREA, 0, prcWorkArea, 0); /* Bail out here if we aren't using multiple monitors */ if (!pScreenInfo->fMultipleMonitors) return TRUE; winDebug ("winGetWorkArea - Original WorkArea: %d %d %d %d\n", (int) prcWorkArea->top, (int) prcWorkArea->left, (int) prcWorkArea->bottom, (int) prcWorkArea->right); /* Get size of full virtual screen */ iWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN); iHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN); winDebug ("winGetWorkArea - Virtual screen is %d x %d\n", iWidth, iHeight); /* Get origin of full virtual screen */ iLeft = GetSystemMetrics (SM_XVIRTUALSCREEN); iTop = GetSystemMetrics (SM_YVIRTUALSCREEN); winDebug ("winGetWorkArea - Virtual screen origin is %d, %d\n", iLeft, iTop); /* Get size of primary screen */ iPrimaryWidth = GetSystemMetrics (SM_CXSCREEN); iPrimaryHeight = GetSystemMetrics (SM_CYSCREEN); winDebug ("winGetWorkArea - Primary screen is %d x %d\n", iPrimaryWidth, iPrimaryHeight); /* Work out how much of the primary screen we aren't using */ iPrimaryNonWorkAreaWidth = iPrimaryWidth - (prcWorkArea->right - prcWorkArea->left); iPrimaryNonWorkAreaHeight = iPrimaryHeight - (prcWorkArea->bottom - prcWorkArea->top); /* Update the rectangle to include all monitors */ if (iLeft < 0) { prcWorkArea->left = iLeft; } if (iTop < 0) { prcWorkArea->top = iTop; } prcWorkArea->right = prcWorkArea->left + iWidth - iPrimaryNonWorkAreaWidth; prcWorkArea->bottom = prcWorkArea->top + iHeight - iPrimaryNonWorkAreaHeight; winDebug ("winGetWorkArea - Adjusted WorkArea for multiple " "monitors: %d %d %d %d\n", (int) prcWorkArea->top, (int) prcWorkArea->left, (int) prcWorkArea->bottom, (int) prcWorkArea->right); return TRUE; }
INT_PTR CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam) { static DWORD dwOldIcon = 0; HICON hIcon = 0; switch(uMsg){ case WM_INITDIALOG: g_hDlgPass = hDlg; hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DLGPASSWD)); dwOldIcon = SetClassLongPtr(hDlg, GCLP_HICON, (LONG)hIcon); // set alt+tab icon SendDlgItemMessage(hDlg,IDC_EDIT1,EM_LIMITTEXT,MAXPASSLEN,0); if (IsAeroMode()) { SetWindowLongPtr(hDlg, GWL_STYLE, GetWindowLongPtr(hDlg, GWL_STYLE) | WS_DLGFRAME | WS_SYSMENU); SetWindowLongPtr(hDlg, GWL_EXSTYLE, GetWindowLongPtr(hDlg, GWL_EXSTYLE) | WS_EX_TOOLWINDOW); RECT rect; GetClientRect(hDlg, &rect); SetWindowPos(hDlg, 0, 0, 0, rect.right, rect.bottom + GetSystemMetrics(SM_CYCAPTION), SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER); } SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)hIcon); SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Miranda NG is locked.\nEnter password to unlock it.")); TranslateDialogDefault(hDlg); oldLangID = 0; SetTimer(hDlg,1,200,NULL); oldLayout = GetKeyboardLayout(0); if (MAKELCID((WORD)oldLayout & 0xffffffff, SORT_DEFAULT) != (LCID)0x00000409) ActivateKeyboardLayout((HKL)0x00000409, 0); LanguageChanged(hDlg); return TRUE; case WM_CTLCOLORSTATIC: if (GetWindowLongPtr((HWND)lParam, GWLP_ID) != IDC_LANG) break; SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT)); SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)GetSysColorBrush(COLOR_HIGHLIGHT); case WM_COMMAND: { UINT uid = LOWORD(wParam); if (uid == IDOK){ char password[MAXPASSLEN + 1] = {0}; int passlen = GetDlgItemTextA(hDlg,IDC_EDIT1,password,MAXPASSLEN+1); if (passlen == 0) { SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Miranda NG is locked.\nEnter password to unlock it.")); SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0); break; } else if (lstrcmpA(password, g_password)) { SetDlgItemText(hDlg, IDC_HEADERBAR, TranslateT("Password is not correct!\nPlease, enter correct password.")); SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_NCPAINT, 0, 0); SetDlgItemText(hDlg, IDC_EDIT1, _T("")); break; } else EndDialog(hDlg, IDOK); } else if (uid == IDCANCEL) EndDialog(hDlg, IDCANCEL); } case WM_TIMER: LanguageChanged(hDlg); break; case WM_DESTROY: KillTimer(hDlg, 1); if (GetKeyboardLayout(0) != oldLayout) ActivateKeyboardLayout(oldLayout, 0); SetClassLongPtr(hDlg, GCLP_HICON, (long)dwOldIcon); DestroyIcon(hIcon); break; } return FALSE; }
// Vista+ only BOOL apiFixFontSizeForBufferSize(HANDLE hOutput, COORD dwSize, char* pszUtfLog /*= NULL*/, int cchLogMax /*= 0*/) { BOOL lbRetry = FALSE; CONSOLE_SCREEN_BUFFER_INFO csbi = {}; if (pszUtfLog) *pszUtfLog = 0; if (dwSize.Y > 0 && dwSize.X > 0 && GetConsoleScreenBufferInfo(hOutput, &csbi)) { COORD crLargest = MyGetLargestConsoleWindowSize(hOutput); int nMaxX = GetSystemMetrics(SM_CXFULLSCREEN); int nMaxY = GetSystemMetrics(SM_CYFULLSCREEN); #ifdef _DEBUG // Для отладки, смотрим какой размер получится по crLargest int nDbgFontX = crLargest.X ? (nMaxX / crLargest.X) : -1; int nDbgFontY = crLargest.Y ? (nMaxY / crLargest.Y) : -1; #endif int curSizeY, curSizeX, newSizeY, newSizeX, calcSizeY, calcSizeX; wchar_t sFontName[LF_FACESIZE]; if (apiGetConsoleFontSize(hOutput, curSizeY, curSizeX, sFontName) && curSizeY && curSizeX) { // Увеличение if (crLargest.X && crLargest.Y && ((dwSize.X > crLargest.X) || (dwSize.Y > crLargest.Y))) { // Теперь прикинуть, какой размер шрифта нам нужен newSizeY = max(1,(nMaxY / (dwSize.Y+1))); newSizeX = max(1,(nMaxX / (dwSize.X+1))); if ((newSizeY < curSizeY) || (newSizeX < curSizeX)) { calcSizeX = newSizeY * curSizeX / curSizeY; calcSizeY = newSizeX * curSizeY / curSizeX; if (calcSizeY < curSizeY) calcSizeX = min(calcSizeX,(calcSizeY * curSizeX / curSizeY)); if (calcSizeX < curSizeX) calcSizeY = min(calcSizeY,(calcSizeX * curSizeY / curSizeX)); newSizeY = max(1,min(calcSizeY,curSizeY)); newSizeX = max(1,min(calcSizeX,curSizeX)); lbRetry = TRUE; } } // Уменьшение else if ((dwSize.X <= (csbi.srWindow.Right - csbi.srWindow.Left)) || (dwSize.Y <= (csbi.srWindow.Bottom - csbi.srWindow.Top))) { int nMinY = GetSystemMetrics(SM_CYMIN) - GetSystemMetrics(SM_CYSIZEFRAME) - GetSystemMetrics(SM_CYCAPTION); int nMinX = GetSystemMetrics(SM_CXMIN) - 2*GetSystemMetrics(SM_CXSIZEFRAME); if ((nMinX > 0) && (nMinY > 0)) { // Теперь прикинуть, какой размер шрифта нам нужен newSizeY = (nMinY / (dwSize.Y)) + 1; // Win8. На базовых настройках разбиение консоли дважды по Ctrl+Shift+O // дает ошибку - размер шрифта в третьей консоли оказывается недостаточным newSizeX = (nMinX / (dwSize.X)) + 2; if ((newSizeY > curSizeY) || (newSizeX > curSizeX)) { calcSizeX = newSizeY * curSizeX / curSizeY; calcSizeY = newSizeX * curSizeY / curSizeX; if (calcSizeY > curSizeY) calcSizeX = max(calcSizeX,(calcSizeY * curSizeX / curSizeY)); if (calcSizeX > curSizeX) calcSizeY = max(calcSizeY,(calcSizeX * curSizeY / curSizeX)); newSizeY = max(calcSizeY,curSizeY); newSizeX = max(calcSizeX,curSizeX); lbRetry = TRUE; } } } if (lbRetry) { lbRetry = apiSetConsoleFontSize(hOutput, newSizeY, newSizeX, sFontName); } } } return lbRetry; }
// // FUNCTION: InitInstance(HANDLE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name RECT rc; hInst = hInstance; // Store instance handle in our global variable LoadString(hInstance, IDC_LK8000, szWindowClass, MAX_LOADSTRING); LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); // If it is already running, then focus on the window // problem was that if two instances are started within a few seconds, both will survive! // We enforceed this with mutex at the beginning of WinMain hWndMainWindow = FindWindow(szWindowClass, szTitle); if (hWndMainWindow) { SetForegroundWindow((HWND)((ULONG) hWndMainWindow | 0x00000001)); return 0; } InitLKScreen(); InitLKFonts(); // causing problems with CreateButtonLabels? PreloadInitialisation(true); MyRegisterClass(hInst, szWindowClass); RECT WindowSize; WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = GetSystemMetrics(SM_CXSCREEN); WindowSize.bottom = GetSystemMetrics(SM_CYSCREEN); #if (WINDOWSPC>0) WindowSize.right = SCREENWIDTH + 2*GetSystemMetrics( SM_CXFIXEDFRAME); WindowSize.left = (GetSystemMetrics(SM_CXSCREEN) - WindowSize.right) / 2; WindowSize.bottom = SCREENHEIGHT + 2*GetSystemMetrics( SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION); WindowSize.top = (GetSystemMetrics(SM_CYSCREEN) - WindowSize.bottom) / 2; /* // // Custom setup for positioning the window , ready to be used // WindowSize.top=768; // top and left corner coords WindowSize.left=1024; WindowSize.right = SCREENWIDTH + 2*GetSystemMetrics( SM_CXFIXEDFRAME); WindowSize.bottom = SCREENHEIGHT + 2*GetSystemMetrics( SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION); */ #endif if (!goInstallSystem) Sleep(50); // 091119 #if TESTBENCH StartupStore(TEXT(". Create main window%s"),NEWLINE); #endif hWndMainWindow = CreateWindow(szWindowClass, szTitle, WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom, NULL, NULL, hInstance, NULL); if (!hWndMainWindow) { return FALSE; } hBrushSelected = (HBRUSH)CreateSolidBrush(ColorSelected); hBrushUnselected = (HBRUSH)CreateSolidBrush(ColorUnselected); hBrushButton = (HBRUSH)CreateSolidBrush(ColorButton); #ifdef LXMINIMAP hBrushButtonHasFocus = (HBRUSH)CreateSolidBrush(ColorButtonHasFocus); #endif GetClientRect(hWndMainWindow, &rc); #if (WINDOWSPC>0) rc.left = 0; rc.right = SCREENWIDTH; rc.top = 0; rc.bottom = SCREENHEIGHT; #endif LKLoadFixedBitmaps(); LKLoadProfileBitmaps(); LKObjects_Create(); ButtonLabel::CreateButtonLabels(rc); ButtonLabel::SetLabelText(0,TEXT("MODE")); extern void InitialiseFonts(RECT rc); InitialiseFonts(rc); InitLKFonts(); // reload updating LK fonts after loading profile for fontquality ButtonLabel::SetFont(MapWindowBoldFont); Message::Initialize(rc); // creates window, sets fonts ShowWindow(hWndMainWindow, SW_SHOW); #if TESTBENCH StartupStore(TEXT(". Create map window%s"),NEWLINE); #endif hWndMapWindow = CreateWindow(TEXT("MapWindowClass"),NULL, WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, (rc.right - rc.left), (rc.bottom-rc.top) , hWndMainWindow, NULL ,hInstance,NULL); ShowWindow(hWndMainWindow, nCmdShow); UpdateWindow(hWndMainWindow); // Since MapWndProc is doing static inits, we want them to be recalculated at the end of // initializations, since some values in use might have been not available yet, for example BottomSize. Reset_Single_DoInits(MDI_MAPWNDPROC); return TRUE; }
static LRESULT STATUSBAR_WMCreate (HWND hwnd, const CREATESTRUCTA *lpCreate) { STATUS_INFO *infoPtr; NONCLIENTMETRICSW nclm; DWORD dwStyle; RECT rect; int len; TRACE("\n"); infoPtr = Alloc (sizeof(STATUS_INFO)); if (!infoPtr) goto create_fail; SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); infoPtr->Self = hwnd; infoPtr->Notify = lpCreate->hwndParent; infoPtr->numParts = 1; infoPtr->parts = 0; infoPtr->simple = FALSE; infoPtr->clrBk = CLR_DEFAULT; infoPtr->hFont = 0; infoPtr->horizontalBorder = HORZ_BORDER; infoPtr->verticalBorder = VERT_BORDER; infoPtr->horizontalGap = HORZ_GAP; infoPtr->minHeight = GetSystemMetrics(SM_CYSIZE); if (infoPtr->minHeight & 1) infoPtr->minHeight--; STATUSBAR_NotifyFormat(infoPtr, infoPtr->Notify, NF_REQUERY); ZeroMemory (&nclm, sizeof(nclm)); nclm.cbSize = sizeof(nclm); SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, nclm.cbSize, &nclm, 0); infoPtr->hDefaultFont = CreateFontIndirectW (&nclm.lfStatusFont); GetClientRect (hwnd, &rect); /* initialize simple case */ infoPtr->part0.bound = rect; infoPtr->part0.text = 0; infoPtr->part0.x = 0; infoPtr->part0.style = 0; infoPtr->part0.hIcon = 0; /* initialize first part */ infoPtr->parts = Alloc (sizeof(STATUSWINDOWPART)); if (!infoPtr->parts) goto create_fail; infoPtr->parts[0].bound = rect; infoPtr->parts[0].text = 0; infoPtr->parts[0].x = -1; infoPtr->parts[0].style = 0; infoPtr->parts[0].hIcon = 0; OpenThemeData (hwnd, themeClass); if (lpCreate->lpszName && (len = strlenW ((LPCWSTR)lpCreate->lpszName))) { infoPtr->parts[0].text = Alloc ((len + 1)*sizeof(WCHAR)); if (!infoPtr->parts[0].text) goto create_fail; strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName); } dwStyle = GetWindowLongW (hwnd, GWL_STYLE); /* native seems to clear WS_BORDER, too */ dwStyle &= ~WS_BORDER; SetWindowLongW (hwnd, GWL_STYLE, dwStyle); infoPtr->height = STATUSBAR_ComputeHeight(infoPtr); if (dwStyle & SBT_TOOLTIPS) { infoPtr->hwndToolTip = CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, WS_POPUP | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, 0, (HINSTANCE)GetWindowLongPtrW(hwnd, GWLP_HINSTANCE), NULL); if (infoPtr->hwndToolTip) { NMTOOLTIPSCREATED nmttc; nmttc.hdr.hwndFrom = hwnd; nmttc.hdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID); nmttc.hdr.code = NM_TOOLTIPSCREATED; nmttc.hwndToolTips = infoPtr->hwndToolTip; SendMessageW (lpCreate->hwndParent, WM_NOTIFY, nmttc.hdr.idFrom, (LPARAM)&nmttc); } } return 0; create_fail: TRACE(" failed!\n"); if (infoPtr) STATUSBAR_WMDestroy(infoPtr); return -1; }
bool IsDbcs() { bool bIsDBCS = (GetSystemMetrics(SM_DBCSENABLED) != 0); return bIsDBCS; }
BOOL fipWinImage::captureWindow(HWND hWndApplicationWindow, HWND hWndSelectedWindow) { int xScreen, yScreen, xshift, yshift; RECT r; // Get window size GetWindowRect(hWndSelectedWindow, &r); // Check if the window is out of the screen or maximixed xshift = 0; yshift = 0; xScreen = GetSystemMetrics(SM_CXSCREEN); yScreen = GetSystemMetrics(SM_CYSCREEN); if(r.right > xScreen) r.right = xScreen; if(r.bottom > yScreen) r.bottom = yScreen; if(r.left < 0) { xshift = -r.left; r.left = 0; } if(r.top < 0){ yshift = -r.top; r.top = 0; } int width = r.right - r.left; int height = r.bottom - r.top; if(width <= 0 || height <= 0) return FALSE; // Hide the application window. ShowWindow(hWndApplicationWindow, SW_HIDE); // Bring the window at the top most level SetWindowPos(hWndSelectedWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); // Give enough time to refresh the window Sleep(500); // Prepare the DCs HDC dstDC = GetDC(NULL); HDC srcDC = GetWindowDC(hWndSelectedWindow); // full window (GetDC(hWndSelectedWindow) = clientarea) HDC memDC = CreateCompatibleDC(dstDC); // Copy the screen to the bitmap HBITMAP bm = CreateCompatibleBitmap(dstDC, width, height); HBITMAP oldbm = (HBITMAP)SelectObject(memDC, bm); BitBlt(memDC, 0, 0, width, height, srcDC, xshift, yshift, SRCCOPY); // Redraw the application window. ShowWindow(hWndApplicationWindow, SW_SHOW); // Restore the position SetWindowPos(hWndSelectedWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); SetWindowPos(hWndApplicationWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); // Convert the HBITMAP to a FIBITMAP copyFromBitmap(bm); // Free objects DeleteObject(SelectObject(memDC, oldbm)); DeleteDC(memDC); // Convert 32-bit images to 24-bit if(getBitsPerPixel() == 32) { convertTo24Bits(); } return TRUE; }
// static int NativeScrollBarWrapper::GetVerticalScrollBarWidth() { return GetSystemMetrics(SM_CXVSCROLL); }
int PlayerWin::run() { INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); // set QUICK_V3_ROOT const char *QUICK_V3_ROOT = getenv("QUICK_V3_ROOT"); if (!QUICK_V3_ROOT || strlen(QUICK_V3_ROOT) == 0) { MessageBox("Please run \"setup_win.bat\", set quick-cocos2d-x root path.", "quick-cocos2d-x player error"); return 1; } SimulatorConfig::getInstance()->setQuickCocos2dxRootPath(QUICK_V3_ROOT); // load project config from command line args vector<string> args; for (int i = 0; i < __argc; ++i) { wstring ws(__wargv[i]); string s; s.assign(ws.begin(), ws.end()); args.push_back(s); } _project.parseCommandLine(args); if (_project.getProjectDir().length() <= 0) { _project.resetToWelcome(); } // set framework path if (!_project.isLoadPrecompiledFramework()) { FileUtils::getInstance()->addSearchPath(SimulatorConfig::getInstance()->getQuickCocos2dxRootPath() + "quick/"); } // create the application instance _app = new AppDelegate(); _app->setProjectConfig(_project); // set window icon HICON icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PLAYER)); // create console window if (_project.isShowConsole()) { AllocConsole(); _hwndConsole = GetConsoleWindow(); if (_hwndConsole != NULL) { SendMessage(_hwndConsole, WM_SETICON, ICON_BIG, (LPARAM)icon); SendMessage(_hwndConsole, WM_SETICON, ICON_SMALL, (LPARAM)icon); ShowWindow(_hwndConsole, SW_SHOW); BringWindowToTop(_hwndConsole); freopen("CONOUT$", "wt", stdout); freopen("CONOUT$", "wt", stderr); HMENU hmenu = GetSystemMenu(_hwndConsole, FALSE); if (hmenu != NULL) DeleteMenu(hmenu, SC_CLOSE, MF_BYCOMMAND); } } // set environments SetCurrentDirectoryA(_project.getProjectDir().c_str()); FileUtils::getInstance()->setSearchRootPath(_project.getProjectDir().c_str()); FileUtils::getInstance()->setWritablePath(_project.getWritableRealPath().c_str()); // check screen DPI HDC screen = GetDC(0); int dpi = GetDeviceCaps(screen, LOGPIXELSX); ReleaseDC(0, screen); // set scale with DPI // 96 DPI = 100 % scaling // 120 DPI = 125 % scaling // 144 DPI = 150 % scaling // 192 DPI = 200 % scaling // http://msdn.microsoft.com/en-us/library/windows/desktop/dn469266%28v=vs.85%29.aspx#dpi_and_the_desktop_scaling_factor // // enable DPI-Aware with DeclareDPIAware.manifest // http://msdn.microsoft.com/en-us/library/windows/desktop/dn469266%28v=vs.85%29.aspx#declaring_dpi_awareness float screenScale = 1.0f; //if (dpi >= 120 && dpi < 144) //{ // screenScale = 1.25f; //} //else if (dpi >= 144 && dpi < 192) //{ // screenScale = 1.5f; //} //else if (dpi >= 192) //{ // screenScale = 2.0f; //} CCLOG("SCREEN DPI = %d, SCREEN SCALE = %0.2f", dpi, screenScale); // create opengl view Size frameSize = _project.getFrameSize(); float frameScale = 1.0f; if (_project.isRetinaDisplay()) { frameSize.width *= screenScale; frameSize.height *= screenScale; } else { frameScale = screenScale; } const Rect frameRect = Rect(0, 0, frameSize.width, frameSize.height); const bool isResize = _project.isResizeWindow(); auto glview = GLViewImpl::createWithRect("quick-cocos2d-x", frameRect, frameScale, isResize); _hwnd = glview->getWin32Window(); SendMessage(_hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon); SendMessage(_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon); FreeResource(icon); auto director = Director::getInstance(); director->setOpenGLView(glview); //director->setScreenScale(screenScale); // set window position if (_project.getProjectDir().length()) { setZoom(_project.getFrameScale()); Vec2 pos = _project.getWindowOffset(); if (pos.x != 0 && pos.y != 0) { glfwSetWindowPos(glview->getWindow(), pos.x, pos.y); } } // init player services initServices(); loadLuaConfig(); registerKeyboardEvent(); // register event handlers auto eventDispatcher = director->getEventDispatcher(); eventDispatcher->addCustomEventListener("APP.WINDOW_CLOSE_EVENT", CC_CALLBACK_1(PlayerWin::onWindowClose, this)); eventDispatcher->addCustomEventListener("APP.WINDOW_RESIZE_EVENT", CC_CALLBACK_1(PlayerWin::onWindowResize, this)); eventDispatcher->addCustomEventListener("APP.VIEW_SCALE", CC_CALLBACK_1(PlayerWin::onWindowScale, this)); // prepare _project.dump(); auto app = Application::getInstance(); glfwSetWin32WindowProc(&PlayerWin::windowProc); HWND hwnd = _hwnd; HWND hwndConsole = _hwndConsole; const ProjectConfig &project = _project; director->getScheduler()->schedule([hwnd, hwndConsole, project](float dt) { CC_UNUSED_PARAM(dt); ShowWindow(hwnd, SW_RESTORE); GLFWwindow *window = dynamic_cast<GLViewImpl*>(Director::getInstance()->getOpenGLView())->getWindow(); glfwShowWindow(window); }, this, 0.0f, 0, 0.001f, false, "SHOW_WINDOW_CALLBACK"); if (project.isAppMenu() && GetMenu(hwnd)) { // update window size RECT rect; GetWindowRect(_hwnd, &rect); MoveWindow(_hwnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top + GetSystemMetrics(SM_CYMENU), FALSE); } ShowWindow(_hwnd, SW_MINIMIZE); // startup message loop return app->run(); }
(GetSystemMetrics(SM_CXSCREEN) - 640)/2, (GetSystemMetrics(SM_CYSCREEN) - 480)/2, RECT window_rect; GetWindowRect(hwnd,&window_rect); AdjustWindowRectEx(&window_rect, GetWindowStyle(hwnd), GetMenu(hwnd)!=NULL, GetWindowExStyle(hwnd)); SetWindowPos(hwnd, HWND_TOP, (GetSystemMetrics(SM_CXSCREEN) - (window_rect.right - window_rect.left))/2, (GetSystemMetrics(SM_CYSCREEN) - (window_rect.bottom - window_rect.top))/2, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, SWP_SHOWWINDOW);
// static int NativeScrollBarWrapper::GetHorizontalScrollBarHeight() { return GetSystemMetrics(SM_CYHSCROLL); }
void CMSWindowsClientTaskBarReceiver::showStatus() { // create the window createWindow(); // lock self while getting status lock(); // get the current status std::string status = getToolTip(); // done getting status unlock(); // update dialog HWND child = GetDlgItem(m_window, IDC_TASKBAR_STATUS_STATUS); SendMessage(child, WM_SETTEXT, 0, (LPARAM)status.c_str()); if (!IsWindowVisible(m_window)) { // position it by the mouse POINT cursorPos; GetCursorPos(&cursorPos); RECT windowRect; GetWindowRect(m_window, &windowRect); int x = cursorPos.x; int y = cursorPos.y; int fw = GetSystemMetrics(SM_CXDLGFRAME); int fh = GetSystemMetrics(SM_CYDLGFRAME); int ww = windowRect.right - windowRect.left; int wh = windowRect.bottom - windowRect.top; int sw = GetSystemMetrics(SM_CXFULLSCREEN); int sh = GetSystemMetrics(SM_CYFULLSCREEN); if (fw < 1) { fw = 1; } if (fh < 1) { fh = 1; } if (x + ww - fw > sw) { x -= ww - fw; } else { x -= fw; } if (x < 0) { x = 0; } if (y + wh - fh > sh) { y -= wh - fh; } else { y -= fh; } if (y < 0) { y = 0; } SetWindowPos(m_window, HWND_TOPMOST, x, y, ww, wh, SWP_SHOWWINDOW); } }
BOOL CTreePropertySheet::OnInitDialog() { CPropertySheet::OnInitDialog(); if(m_bSpecialCaption) { CRect rcWindow; ModifyStyle(WS_CAPTION,0,0); ModifyStyle(WS_SYSMENU,0,0); GetWindowRect(&rcWindow); rcWindow.bottom-=GetSystemMetrics(SM_CYCAPTION); MoveWindow(&rcWindow,FALSE); } if(m_bDisableStandardButtons) HidePpgButtons(); HideTabControl(); AddTreeView(); AlignControls(); int nPage,nPages=m_acPropPages.GetSize(); CArray<HTREEITEM,HTREEITEM> stack; for(nPage=0;nPage<nPages;nPage++) { cPropPage& page=m_acPropPages[nPage]; HTREEITEM parent=stack.GetSize()?stack[stack.GetSize()-1]:TVI_ROOT; HTREEITEM cur=NULL; if(page.sCaption.GetLength()==0) GetPage(nPage)->GetWindowText(page.sCaption); cur =m_cTreeCtrl.InsertItem(page.sCaption,parent); m_cTreeCtrl.SetItemData(cur,nPage); int nType=page.nType&tps_item_type_mask; if(nType==tps_item_branch) stack.Add(cur); if(nType==tps_item_endbranch) stack.SetSize(stack.GetSize()-1); if(page.nType&tps_item_expanded) m_cTreeCtrl.SetItemState(cur, TVIS_EXPANDED, TVIS_EXPANDED); if (nPage == m_iWantedPage) m_cTreeCtrl.Select (cur, TVGN_CARET); } if(m_pCaptionFont==NULL) SetCaptionFont("MS Sans Serif",18,TRUE); if(m_pCaptionDescrFont==NULL) SetCaptionDescrFont("MS Sans Serif",18,TRUE); // remove apply button CWnd* pTemp; pTemp = GetDlgItem(ID_APPLY_NOW); if (pTemp) pTemp->ShowWindow (SW_HIDE); return TRUE; // return TRUE unless you set the focus to a control }
Bool winCreateBoundingWindowFullScreen (ScreenPtr pScreen) { winScreenPriv(pScreen); winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; int iX = pScreenInfo->dwInitialX; int iY = pScreenInfo->dwInitialY; int iWidth = pScreenInfo->dwWidth; int iHeight = pScreenInfo->dwHeight; HWND *phwnd = &pScreenPriv->hwndScreen; WNDCLASSEX wc; char szTitle[256]; #if CYGDEBUG winDebug ("winCreateBoundingWindowFullScreen\n"); #endif /* Setup our window class */ wc.cbSize=sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = winWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_hInstance; wc.hIcon = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0); wc.hCursor = 0; wc.hbrBackground = 0; wc.lpszMenuName = NULL; wc.lpszClassName = WINDOW_CLASS; wc.hIconSm = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTSIZE); RegisterClassEx (&wc); /* Set display and screen-specific tooltip text */ if (g_pszQueryHost != NULL) snprintf (szTitle, sizeof (szTitle), WINDOW_TITLE_XDMCP, g_pszQueryHost, display, (int) pScreenInfo->dwScreen); else snprintf (szTitle, sizeof (szTitle), WINDOW_TITLE, display, (int) pScreenInfo->dwScreen); /* Create the window */ *phwnd = CreateWindowExA (0, /* Extended styles */ WINDOW_CLASS, /* Class name */ szTitle, /* Window name */ WS_POPUP, iX, /* Horizontal position */ iY, /* Vertical position */ iWidth, /* Right edge */ iHeight, /* Bottom edge */ (HWND) NULL, /* No parent or owner window */ (HMENU) NULL, /* No menu */ GetModuleHandle (NULL),/* Instance handle */ pScreenPriv); /* ScreenPrivates */ /* Branch on the server engine */ switch (pScreenInfo->dwEngine) { #ifdef XWIN_NATIVEGDI case WIN_SERVER_SHADOW_GDI: /* Show the window */ ShowWindow (*phwnd, SW_SHOWMAXIMIZED); break; #endif default: /* Hide the window */ ShowWindow (*phwnd, SW_SHOWNORMAL); break; } /* Send first paint message */ UpdateWindow (*phwnd); /* Attempt to bring our window to the top of the display */ BringWindowToTop (*phwnd); return TRUE; }
static LRESULT CALLBACK EventArea_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_MEASUREITEM: { MEASUREITEMSTRUCT *lpi = (LPMEASUREITEMSTRUCT)lParam; MENUITEMINFOA mii = { 0 }; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA | MIIM_ID; if (GetMenuItemInfoA(g_CluiData.hMenuNotify, lpi->itemID, FALSE, &mii) != 0) { if (mii.dwItemData == lpi->itemData) { lpi->itemWidth = 8 + 16; lpi->itemHeight = 0; return TRUE; } } } break; case WM_DRAWITEM: { LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; if (dis->hwndItem == (HWND)g_CluiData.hMenuNotify) { MENUITEMINFOA mii = { 0 }; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA; if (GetMenuItemInfoA(g_CluiData.hMenuNotify, (UINT)dis->itemID, FALSE, &mii) != 0) { NotifyMenuItemExData *nmi = (NotifyMenuItemExData *)mii.dwItemData; if (nmi) { int iIcon = Clist_GetContactIcon(nmi->hContact); ske_ImageList_DrawEx(g_himlCListClc, nmi->iIcon, dis->hDC, 2, (dis->rcItem.bottom + dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), CLR_NONE, CLR_NONE, ILD_NORMAL); ske_ImageList_DrawEx(g_himlCListClc, iIcon, dis->hDC, 2 + GetSystemMetrics(SM_CXSMICON) + 2, (dis->rcItem.bottom + dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), CLR_NONE, CLR_NONE, ILD_NORMAL); return TRUE; } } } } break; case WM_LBUTTONUP: if (g_CluiData.bEventAreaEnabled) SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_NOTIFYBUTTON, 0), 0); break; case WM_COMMAND: if (LOWORD(wParam) == IDC_NOTIFYBUTTON) { POINT pt; GetCursorPos(&pt); MENUITEMINFO mii = { 0 }; mii.cbSize = sizeof(mii); mii.fMask = MIIM_DATA; int iSelection; if (GetMenuItemCount(g_CluiData.hMenuNotify) > 1) iSelection = TrackPopupMenu(g_CluiData.hMenuNotify, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, nullptr); else iSelection = GetMenuItemID(g_CluiData.hMenuNotify, 0); BOOL result = GetMenuItemInfo(g_CluiData.hMenuNotify, (UINT)iSelection, FALSE, &mii); if (result != 0) { NotifyMenuItemExData *nmi = (NotifyMenuItemExData*)mii.dwItemData; if (nmi) { CLISTEVENT *cle = MyGetEvent(iSelection); if (cle) { CLISTEVENT *cle1 = nullptr; CallService(cle->pszService, (WPARAM)nullptr, (LPARAM)cle); // re-obtain the pointer, it may already be invalid/point to another event if the // event we're interested in was removed by the service (nasty one...) cle1 = MyGetEvent(iSelection); if (cle1 != nullptr) g_clistApi.pfnRemoveEvent(cle->hContact, cle->hDbEvent); } } } break; } break; case WM_SIZE: if (!g_CluiData.fLayered) InvalidateRect(hwnd, nullptr, FALSE); return DefWindowProc(hwnd, msg, wParam, lParam); case WM_ERASEBKGND: return 1; case WM_PAINT: if (GetParent(hwnd) == g_clistApi.hwndContactList && g_CluiData.fLayered) CallService(MS_SKINENG_INVALIDATEFRAMEIMAGE, (WPARAM)hwnd, 0); else if (GetParent(hwnd) == g_clistApi.hwndContactList && !g_CluiData.fLayered) { RECT rc = { 0 }; GetClientRect(hwnd, &rc); rc.right++; rc.bottom++; HDC hdc = GetDC(hwnd); HDC hdc2 = CreateCompatibleDC(hdc); HBITMAP hbmp = ske_CreateDIB32(rc.right, rc.bottom); HBITMAP hbmpo = (HBITMAP)SelectObject(hdc2, hbmp); ske_BltBackImage(hwnd, hdc2, &rc); EventArea_DrawWorker(hwnd, hdc2); BitBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hdc2, rc.left, rc.top, SRCCOPY); SelectObject(hdc2, hbmpo); DeleteObject(hbmp); DeleteDC(hdc2); SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); ReleaseDC(hwnd, hdc); ValidateRect(hwnd, nullptr); } else { RECT rc; GetClientRect(hwnd, &rc); HBRUSH br = GetSysColorBrush(COLOR_3DFACE); PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); HDC hdc2 = CreateCompatibleDC(hdc); HBITMAP hbmp = ske_CreateDIB32(rc.right, rc.bottom); HBITMAP hbmpo = (HBITMAP)SelectObject(hdc2, hbmp); FillRect(hdc2, &ps.rcPaint, br); EventArea_DrawWorker(hwnd, hdc2); BitBlt(hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top, hdc2, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); SelectObject(hdc2, hbmpo); DeleteObject(hbmp); DeleteDC(hdc2); ps.fErase = FALSE; EndPaint(hwnd, &ps); } default: return DefWindowProc(hwnd, msg, wParam, lParam); } return TRUE; }
// *** IContextMenu methods *** STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT /*uFlags*/) { UINT idCmd = idCmdFirst; FORMATETC fmte = { CF_HDROP, (DVTARGETDEVICE FAR *)NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; HRESULT hres = m_pDataObj->GetData(&fmte, &m_stgMedium); if (SUCCEEDED(hres)) { if (m_stgMedium.hGlobal) m_cbFiles = DragQueryFile((HDROP)m_stgMedium.hGlobal, (UINT)-1, 0, 0); } UINT nIndex = indexMenu++; InsertMenu(hMenu, nIndex, MF_STRING|MF_BYPOSITION, idCmd++, m_szMenuTitle); if (m_showIcon) { HBITMAP icon = NULL; if (m_winVer >= WINVER_VISTA) { icon = NULL; HICON hicon; DWORD menuIconWidth = GetSystemMetrics(SM_CXMENUCHECK); DWORD menuIconHeight = GetSystemMetrics(SM_CYMENUCHECK); HRESULT hr = LoadShellIcon(menuIconWidth, menuIconHeight, &hicon); if (SUCCEEDED(hr)) { icon = IconToBitmapPARGB32(hicon, menuIconWidth, menuIconHeight); DestroyIcon(hicon); } } else { icon = HBMMENU_CALLBACK; } if (icon != NULL) { MENUITEMINFO mii; ZeroMemory(&mii, sizeof(mii)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_BITMAP; mii.hbmpItem = icon; //mii.hbmpChecked = icon; //mii.hbmpUnchecked = icon; SetMenuItemInfo(hMenu, nIndex, MF_BYPOSITION, &mii); if (m_winVer >= WINVER_VISTA) { MENUINFO MenuInfo; MenuInfo.cbSize = sizeof(MenuInfo); MenuInfo.fMask = MIM_STYLE; MenuInfo.dwStyle = MNS_CHECKORBMP; SetMenuInfo(hMenu, &MenuInfo); } } } m_hMenu = hMenu; m_menuID = idCmd; return ResultFromShort(idCmd-idCmdFirst); }
void ApplicationObject::InitializeWindow(int width, int height, const bool& fullscreen) { WNDCLASSEX wc; DEVMODE dmScreenSettings; DWORD ExStyle, Style; RECT WindowSize; ExStyle = WS_EX_APPWINDOW; Style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_POPUP; wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = m_instance; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hIconSm = wc.hIcon; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = m_name; wc.cbSize = sizeof(WNDCLASSEX); RegisterClassEx(&wc); if(fullscreen) { width = GetSystemMetrics(SM_CXSCREEN); height = GetSystemMetrics(SM_CYSCREEN); memset(&dmScreenSettings, 0, sizeof(dmScreenSettings)); dmScreenSettings.dmSize = sizeof(dmScreenSettings); dmScreenSettings.dmPelsWidth = (unsigned long)width; dmScreenSettings.dmPelsHeight = (unsigned long)height; dmScreenSettings.dmBitsPerPel = 32; dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN); WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = GetSystemMetrics(SM_CXSCREEN); WindowSize.bottom = GetSystemMetrics(SM_CYSCREEN); } else { width = 1280; height = 720; WindowSize.left = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; WindowSize.top = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; WindowSize.right = WindowSize.left + width; WindowSize.bottom = WindowSize.top + height; } m_fullscreen = fullscreen; m_width = width; m_height = height; AdjustWindowRectEx(&WindowSize, Style, FALSE, ExStyle); m_hwnd = CreateWindowEx(ExStyle, m_name, m_name, Style, WindowSize.left, WindowSize.top, WindowSize.right-WindowSize.left, WindowSize.bottom-WindowSize.top, NULL, NULL, m_instance, NULL); ShowWindow(m_hwnd, SW_SHOW); SetForegroundWindow(m_hwnd); SetFocus(m_hwnd); m_graphics = new GraphicsObject(m_hwnd, m_width, m_height, m_fullscreen); m_input = new InputObject(); if (!m_input->Initialize(m_instance, m_hwnd, m_width, m_height)) MessageBox(m_hwnd, L"HEY SOMETHING WENT WRONG", L"ERROR OR SOMETHING", 0); return; }
void CMuleToolbarCtrl::SetAllButtonsWidth() { if (GetButtonCount() == 0) return; if (m_eLabelType == LabelsBelow) { CDC *pDC = GetDC(); CFont *pFnt = GetFont(); CFont *pOldFnt = pDC->SelectObject(pFnt); CRect r(0,0,0,0); // calculate the max. possible button-size int iCalcSize = 0; for (int i = 0; i < m_buttoncount ; i++) { if (!IsButtonHidden(IDC_TOOLBARBUTTON + i)) { pDC->DrawText(TBStrings[i], -1, r, DT_SINGLELINE | DT_CALCRECT); if (r.Width() > iCalcSize) iCalcSize = r.Width(); } } iCalcSize += 10; pDC->SelectObject(pOldFnt); ReleaseDC(pDC); if (!thePrefs.GetUseReBarToolbar()) { GetClientRect(&r); int bc = GetButtonCount(); if (bc == 0) bc = 1; int iMaxPossible = r.Width() / bc; // if the buttons are to big, reduze their size if (iCalcSize > iMaxPossible) iCalcSize = iMaxPossible; } else { if (iCalcSize < 56) iCalcSize = 56; else if (iCalcSize > 72) iCalcSize = 72; } SetButtonWidth(iCalcSize, iCalcSize); } else { int iSmallIconsButtonHeight; if (theApp.m_ullComCtrlVer < MAKEDLLVERULL(6, 0, 0, 0)) { // Win98,WinME,Win2000: Comtrl32 prior to 6.0 cannot make a toolbar smaller than 22 pixels // in height and if it gets larger than 22 pixels the icons do not get centered vertically. iSmallIconsButtonHeight = 22; } else iSmallIconsButtonHeight = GetSystemMetrics(SM_CYSCREEN) <= 600 ? 16 : 28; if (m_eLabelType == NoLabels) { DWORD dwSize = GetButtonSize(); int iFixedButtonWidth; int iFixedButtonHeight = HIWORD(dwSize); if (m_sizBtnBmp.cx == 16) { iFixedButtonWidth = 28; iFixedButtonHeight = iSmallIconsButtonHeight; } else { iFixedButtonWidth = 56; } // it seems that the control updates itself more properly, if 'SetButtonWidth' id called *before* 'SetButtonSize' SetButtonWidth(iFixedButtonWidth, iFixedButtonWidth); SetButtonSize(CSize(iFixedButtonWidth, iFixedButtonHeight)); } else { int iFixedButtonHeight = 0; if (m_sizBtnBmp.cx == 16) iFixedButtonHeight = iSmallIconsButtonHeight; // it seems that the control updates itself more properly, if 'SetButtonWidth' id called *before* 'SetButtonSize' SetButtonWidth(0, 0); SetButtonSize(CSize(0, iFixedButtonHeight)); } } }
Bool winCreateBoundingWindowWindowed (ScreenPtr pScreen) { winScreenPriv(pScreen); winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; int iWidth = pScreenInfo->dwUserWidth; int iHeight = pScreenInfo->dwUserHeight; int iPosX; int iPosY; HWND *phwnd = &pScreenPriv->hwndScreen; WNDCLASSEX wc; RECT rcClient, rcWorkArea; DWORD dwWindowStyle; BOOL fForceShowWindow = FALSE; char szTitle[256]; winDebug ("winCreateBoundingWindowWindowed - User w: %d h: %d\n", (int) pScreenInfo->dwUserWidth, (int) pScreenInfo->dwUserHeight); winDebug ("winCreateBoundingWindowWindowed - Current w: %d h: %d\n", (int) pScreenInfo->dwWidth, (int) pScreenInfo->dwHeight); /* Set the common window style flags */ dwWindowStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX; /* Decorated or undecorated window */ if (pScreenInfo->fDecoration #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM #endif && !pScreenInfo->fRootless #ifdef XWIN_MULTIWINDOW && !pScreenInfo->fMultiWindow #endif ) { /* Try to handle startup via run.exe. run.exe instructs Windows to * hide all created windows. Detect this case and make sure the * window is shown nevertheless */ STARTUPINFO startupInfo; GetStartupInfo(&startupInfo); if (startupInfo.dwFlags & STARTF_USESHOWWINDOW && startupInfo.wShowWindow == SW_HIDE) { fForceShowWindow = TRUE; } dwWindowStyle |= WS_CAPTION; if (pScreenInfo->iResizeMode != notAllowed) dwWindowStyle |= WS_THICKFRAME | WS_MAXIMIZEBOX; } else dwWindowStyle |= WS_POPUP; /* Setup our window class */ wc.cbSize=sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = winWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = g_hInstance; wc.hIcon = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0); wc.hCursor = 0; wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = WINDOW_CLASS; wc.hIconSm = (HICON)LoadImage (g_hInstance, MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTSIZE); RegisterClassEx (&wc); /* Get size of work area */ winGetWorkArea (&rcWorkArea, pScreenInfo); /* Adjust for auto-hide taskbars */ winAdjustForAutoHide (&rcWorkArea); /* Did the user specify a position? */ if (pScreenInfo->fUserGavePosition) { iPosX = pScreenInfo->dwInitialX; iPosY = pScreenInfo->dwInitialY; } else { iPosX = rcWorkArea.left; iPosY = rcWorkArea.top; } /* Clean up the scrollbars flag, if necessary */ if ((!pScreenInfo->fDecoration #ifdef XWIN_MULTIWINDOWEXTWM || pScreenInfo->fMWExtWM #endif || pScreenInfo->fRootless #ifdef XWIN_MULTIWINDOW || pScreenInfo->fMultiWindow #endif ) && (pScreenInfo->iResizeMode == resizeWithScrollbars)) { /* We cannot have scrollbars if we do not have a window border */ pScreenInfo->iResizeMode = notAllowed; } /* Did the user specify a height and width? */ if (pScreenInfo->fUserGaveHeightAndWidth) { /* User gave a desired height and width, try to accomodate */ #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - User gave height " "and width\n"); #endif /* Adjust the window width and height for borders and title bar */ if (pScreenInfo->fDecoration #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM #endif && !pScreenInfo->fRootless #ifdef XWIN_MULTIWINDOW && !pScreenInfo->fMultiWindow #endif ) { #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - Window has decoration\n"); #endif /* Are we resizable */ if (pScreenInfo->iResizeMode != notAllowed) { #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - Window is resizable\n"); #endif iWidth += 2 * GetSystemMetrics (SM_CXSIZEFRAME); iHeight += 2 * GetSystemMetrics (SM_CYSIZEFRAME) + GetSystemMetrics (SM_CYCAPTION); } else { #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - Window is not resizable\n"); #endif iWidth += 2 * GetSystemMetrics (SM_CXFIXEDFRAME); iHeight += 2 * GetSystemMetrics (SM_CYFIXEDFRAME) + GetSystemMetrics (SM_CYCAPTION); } } } else { /* By default, we are creating a window that is as large as possible */ #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - User did not give " "height and width\n"); #endif /* Defaults are wrong if we have multiple monitors */ if (pScreenInfo->fMultipleMonitors) { iWidth = GetSystemMetrics (SM_CXVIRTUALSCREEN); iHeight = GetSystemMetrics (SM_CYVIRTUALSCREEN); } } /* Make sure window is no bigger than work area */ if (TRUE #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM #endif #ifdef XWIN_MULTIWINDOW && !pScreenInfo->fMultiWindow #endif ) { /* Trim window width to fit work area */ if (iWidth > (rcWorkArea.right - rcWorkArea.left)) iWidth = rcWorkArea.right - rcWorkArea.left; /* Trim window height to fit work area */ if (iHeight >= (rcWorkArea.bottom - rcWorkArea.top)) iHeight = rcWorkArea.bottom - rcWorkArea.top; #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - Adjusted width: %d "\ "height: %d\n", iWidth, iHeight); #endif } /* Set display and screen-specific tooltip text */ if (g_pszQueryHost != NULL) snprintf (szTitle, sizeof (szTitle), WINDOW_TITLE_XDMCP, g_pszQueryHost, display, (int) pScreenInfo->dwScreen); else snprintf (szTitle, sizeof (szTitle), WINDOW_TITLE, display, (int) pScreenInfo->dwScreen); /* Create the window */ *phwnd = CreateWindowExA (0, /* Extended styles */ WINDOW_CLASS, /* Class name */ szTitle, /* Window name */ dwWindowStyle, iPosX, /* Horizontal position */ iPosY, /* Vertical position */ iWidth, /* Right edge */ iHeight, /* Bottom edge */ (HWND) NULL, /* No parent or owner window */ (HMENU) NULL, /* No menu */ GetModuleHandle (NULL),/* Instance handle */ pScreenPriv); /* ScreenPrivates */ if (*phwnd == NULL) { ErrorF ("winCreateBoundingWindowWindowed - CreateWindowEx () failed\n"); return FALSE; } #if CYGDEBUG winDebug ("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n"); #endif if (fForceShowWindow) { ErrorF("winCreateBoundingWindowWindowed - Setting normal windowstyle\n"); ShowWindow(*phwnd, SW_SHOW); } /* Get the client area coordinates */ if (!GetClientRect (*phwnd, &rcClient)) { ErrorF ("winCreateBoundingWindowWindowed - GetClientRect () " "failed\n"); return FALSE; } winDebug ("winCreateBoundingWindowWindowed - WindowClient " "w %ld h %ld r %ld l %ld b %ld t %ld\n", rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, rcClient.right, rcClient.left, rcClient.bottom, rcClient.top); /* We adjust the visual size if the user did not specify it */ if (!((pScreenInfo->iResizeMode == resizeWithScrollbars) && pScreenInfo->fUserGaveHeightAndWidth)) { /* * User did not give a height and width with scrollbars enabled, * so we will resize the underlying visual to be as large as * the initial view port (page size). This way scrollbars will * not appear until the user shrinks the window, if they ever do. * * NOTE: We have to store the viewport size here because * the user may have an autohide taskbar, which would * cause the viewport size to be one less in one dimension * than the viewport size that we calculated by subtracting * the size of the borders and caption. */ pScreenInfo->dwWidth = rcClient.right - rcClient.left; pScreenInfo->dwHeight = rcClient.bottom - rcClient.top; } #if 0 /* * NOTE: For the uninitiated, the page size is the number of pixels * that we can display in the x or y direction at a time and the * range is the total number of pixels in the x or y direction that we * have available to display. In other words, the page size is the * size of the window area minus the space the caption, borders, and * scrollbars (if any) occupy, and the range is the size of the * underlying X visual. Notice that, contrary to what some of the * MSDN Library arcticles lead you to believe, the windows * ``client area'' size does not include the scrollbars. In other words, * the whole client area size that is reported to you is drawable by * you; you do not have to subtract the size of the scrollbars from * the client area size, and if you did it would result in the size * of the scrollbars being double counted. */ /* Setup scrollbar page and range, if scrollbars are enabled */ if (pScreenInfo->fScrollbars) { SCROLLINFO si; /* Initialize the scrollbar info structure */ si.cbSize = sizeof (si); si.fMask = SIF_RANGE | SIF_PAGE; si.nMin = 0; /* Setup the width range and page size */ si.nMax = pScreenInfo->dwWidth - 1; si.nPage = rcClient.right - rcClient.left; winDebug ("winCreateBoundingWindowWindowed - HORZ nMax: %d nPage :%d\n", si.nMax, si.nPage); SetScrollInfo (*phwnd, SB_HORZ, &si, TRUE); /* Setup the height range and page size */ si.nMax = pScreenInfo->dwHeight - 1; si.nPage = rcClient.bottom - rcClient.top; winDebug ("winCreateBoundingWindowWindowed - VERT nMax: %d nPage :%d\n", si.nMax, si.nPage); SetScrollInfo (*phwnd, SB_VERT, &si, TRUE); } #endif /* Show the window */ if (FALSE #ifdef XWIN_MULTIWINDOWEXTWM || pScreenInfo->fMWExtWM #endif #ifdef XWIN_MULTIWINDOW || pScreenInfo->fMultiWindow #endif ) { #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) pScreenPriv->fRootWindowShown = FALSE; #endif ShowWindow (*phwnd, SW_HIDE); } else ShowWindow (*phwnd, SW_SHOWNORMAL); if (!UpdateWindow (*phwnd)) { ErrorF ("winCreateBoundingWindowWindowed - UpdateWindow () failed\n"); return FALSE; } /* Attempt to bring our window to the top of the display */ if (TRUE #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM #endif && !pScreenInfo->fRootless #ifdef XWIN_MULTIWINDOW && !pScreenInfo->fMultiWindow #endif ) { if (!BringWindowToTop (*phwnd)) { ErrorF ("winCreateBoundingWindowWindowed - BringWindowToTop () " "failed\n"); return FALSE; } } #ifdef XWIN_NATIVEGDI /* Paint window background blue */ if (pScreenInfo->dwEngine == WIN_SERVER_NATIVE_GDI) winPaintBackground (*phwnd, RGB (0x00, 0x00, 0xFF)); #endif winDebug ("winCreateBoundingWindowWindowed - Returning\n"); return TRUE; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int result = prepare(lpCmdLine); if (result == ERROR_ALREADY_EXISTS) { HWND handle = getInstanceWindow(); ShowWindow(handle, SW_SHOW); SetForegroundWindow(handle); closeLogFile(); return 2; } if (result != TRUE) { signalError(); return 1; } splash = loadBool(SHOW_SPLASH) && strstr(lpCmdLine, "--l4j-no-splash") == NULL; restartOnCrash = loadBool(RESTART_ON_CRASH); // if we should restart on crash, we must also stay alive to check for crashes stayAlive = restartOnCrash || (loadBool(GUI_HEADER_STAYS_ALIVE) && strstr(lpCmdLine, "--l4j-dont-wait") == NULL); if (splash || stayAlive) { hWnd = CreateWindowEx(WS_EX_TOOLWINDOW, "STATIC", "", WS_POPUP | SS_BITMAP, 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); if (splash) { char timeout[10] = {0}; if (loadString(SPLASH_TIMEOUT, timeout)) { splashTimeout = atoi(timeout); if (splashTimeout <= 0 || splashTimeout > MAX_SPLASH_TIMEOUT) { splashTimeout = DEFAULT_SPLASH_TIMEOUT; } } splashTimeoutErr = loadBool(SPLASH_TIMEOUT_ERR) && strstr(lpCmdLine, "--l4j-no-splash-err") == NULL; waitForWindow = loadBool(SPLASH_WAITS_FOR_WINDOW); HANDLE hImage = LoadImage(hInstance, // handle of the instance containing the image MAKEINTRESOURCE(SPLASH_BITMAP), // name or identifier of image IMAGE_BITMAP, // type of image 0, // desired width 0, // desired height LR_DEFAULTSIZE); if (hImage == NULL) { signalError(); return 1; } SendMessage(hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hImage); RECT rect; GetWindowRect(hWnd, &rect); int x = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2; int y = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2; SetWindowPos(hWnd, HWND_TOP, x, y, 0, 0, SWP_NOSIZE); ShowWindow(hWnd, nCmdShow); UpdateWindow (hWnd); } } do { if (splash || stayAlive) { if (!SetTimer (hWnd, ID_TIMER, 1000 /* 1s */, TimerProc)) { signalError(); return 1; } } if (!execute(FALSE, &dwExitCode)) { signalError(); return 1; } if (!(splash || stayAlive)) { debug("Exit code:\t0\n"); closeProcessHandles(); closeLogFile(); return 0; } MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } if (restartOnCrash && dwExitCode != 0) { debug("Exit code:\t%d, restarting the application!\n", dwExitCode); } closeProcessHandles(); } while (restartOnCrash && dwExitCode != 0); debug("Exit code:\t%d\n", dwExitCode); closeLogFile(); return dwExitCode; }
//--------------------------------------------------------------------------- LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { HDC hdc; HWND hWndDateTimePicker, hWndOK; LONG ptrStyles = GetWindowLong(hWndDlg, GWL_STYLE); // This will represent the dimensions of the whole screen RECT rctClient; // Create a black brush HBRUSH BlackBrush; // Select the black brush HBRUSH oldBrush =(HBRUSH) GetSysColor(COLOR_BACKGROUND); hWndDateTimePicker = GetDlgItem(hWndDlg, IDC_TIMETOWAKEUP); hWndOK = GetDlgItem(hWndDlg, IDOK); SYSTEMTIME tmeCurrent; switch (Msg) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch (wParam) { case IDCANCEL: EndDialog(hWndDlg, 0); return TRUE; case IDC_SET_BTN: // Get the time that the user had set and store it // in the tmeSet variable DateTime_GetSystemtime(hWndDateTimePicker, &tmeSet); TCHAR str[20]; GetTimeFormat( MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT), 0, &tmeSet, NULL, str, 20); MessageBox(hWndDlg, str, _T("System Time"), MB_OK); hdc = GetDC(hWndDlg); BlackBrush = CreateSolidBrush(RGB(0, 0, 0)); SelectObject(hdc, BlackBrush); // TODO: Add your control notification handler code here // Get the screen dimensions DialogWidth = GetSystemMetrics(SM_CXSCREEN); DialogHeight = GetSystemMetrics(SM_CYSCREEN); // When sets the clock wave sound, remove the title bar and the borders ptrStyles &= ~WS_TILEDWINDOW; SetWindowLong(hWndDlg, GWL_STYLE, ptrStyles); // Occupy the whole screen SetWindowPos(hWndDlg, HWND_TOPMOST, 0, 0, DialogWidth, DialogHeight, SWP_SHOWWINDOW); // Get the dimension of the current dialog box GetWindowRect(hWndDlg, &rctClient); // Paint the dialog box in black Rectangle(hdc, rctClient.left, rctClient.top, rctClient.right, rctClient.bottom); // Restore the original brush //SelectObject(hdc, oldBrush); // Start the timer control SetTimer(hWndDlg, IDC_CHECKTIME, 2000, 0); // We don't need to see the cursor ShowCursor(FALSE); ReleaseDC(hWndDlg, hdc); return TRUE; } break; case WM_TIMER: // Get the current time on the computer GetLocalTime(&tmeCurrent); // Compare the current time with the time the user had set // If they are the same, then start playing the CD if ((tmeCurrent.wYear == tmeSet.wYear) && (tmeCurrent.wMonth == tmeSet.wMonth) && //(tmeCurrent.wDayOfWeek == tmeSet.wDayOfWeek) && (tmeCurrent.wDay == tmeSet.wDay) && (tmeCurrent.wHour == tmeSet.wHour) && (tmeCurrent.wMinute == tmeSet.wMinute) /* && (tmeCurrent.wSecond == tmeSet.wSecond) && (tmeCurrent.wMilliseconds == tmeSet.wMilliseconds) */) { //mciSendString(_T("play waveaudio!Audio/click.wav"), NULL, 0, NULL); PlaySound(MAKEINTRESOURCE(IDR_SOUND), hInst, SND_RESOURCE | SND_ASYNC); } break; case WM_CLOSE: PostQuitMessage(WM_QUIT); break; case WM_DESTROY: // However the user decides to close the dialog box, // stop playing the audio file //mciSendString(_T("stop waveaudio"), NULL, 0, NULL); PlaySound(NULL, 0, 0); KillTimer(hWndDlg, IDC_CHECKTIME); break; } return FALSE; }
git_revnum_t GitStatus::GetStatus(const CTGitPath& path, bool update /* = false */, bool noignore /* = false */, bool /*noexternals*/ /* = false */) { // NOTE: unlike the SVN version this one does not cache the enumerated files, because in practice no code in all of // Tortoise uses this, all places that call GetStatus create a temp GitStatus object which gets destroyed right // after the call again // apr_hash_t * statushash; // apr_hash_t * exthash; // apr_array_header_t * statusarray; // const sort_item* item; // git_error_clear(m_err); // statushash = apr_hash_make(m_pool); // exthash = apr_hash_make(m_pool); git_revnum_t youngest = GIT_INVALID_REVNUM; // git_opt_revision_t rev; // rev.kind = git_opt_revision_unspecified; CString sProjectRoot; if ( !path.HasAdminDir(&sProjectRoot) ) return youngest; struct hashbaton_t hashbaton; // hashbaton.hash = statushash; // hashbaton.exthash = exthash; hashbaton.pThis = this; bool isfull = ((DWORD)CRegStdDWORD(_T("Software\\TortoiseGit\\CacheType"), GetSystemMetrics(SM_REMOTESESSION) ? ShellCache::dll : ShellCache::exe) == ShellCache::dllFull); { LPCTSTR lpszSubPath = NULL; CString sSubPath; CString s = path.GetWinPathString(); if (s.GetLength() > sProjectRoot.GetLength()) { sSubPath = s.Right(s.GetLength() - sProjectRoot.GetLength()); lpszSubPath = sSubPath; // skip initial slash if necessary if (*lpszSubPath == _T('\\')) lpszSubPath++; } m_status.prop_status = m_status.text_status = git_wc_status_none; if(path.IsDirectory()) { m_err = GetDirStatus(sProjectRoot,CString(lpszSubPath),&m_status.text_status , isfull, false,!noignore, NULL, NULL); } else { m_err = GetFileStatus(sProjectRoot,CString(lpszSubPath),&m_status.text_status ,isfull, false,!noignore, NULL,NULL); } } // Error present if function is not under version control if (m_err) /*|| (apr_hash_count(statushash) == 0)*/ { status = NULL; return GIT_INVALID_REVNUM; } // Convert the unordered hash to an ordered, sorted array /*statusarray = sort_hash (statushash, sort_compare_items_as_paths, m_pool);*/ // only the first entry is needed (no recurse) // item = &APR_ARRAY_IDX (statusarray, 0, const sort_item); // status = (git_wc_status2_t *) item->value; status = &m_status; if (update) { // done to match TSVN functionality of this function (not sure if any code uses the reutrn val) // if TGit does not need this, then change the return type of function youngest = g_Git.GetHash(_T("HEAD")); } return youngest; }
// returns the smallest rectangle that covers the entire virtual screen (all monitors) RectI GetVirtualScreenRect() { RectI result(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); EnumDisplayMonitors(NULL, NULL, GetMonitorRectProc, (LPARAM)&result); return result; }
//Basic Init, create the font, backbuffer, etc WINDOW *initscr(void) { // _windows = new WINDOW[20]; //initialize all of our variables BITMAPINFO bmi; lastchar=-1; inputdelay=-1; std::string typeface; char * typeface_c; std::ifstream fin; fin.open("data\\FONTDATA"); if (!fin.is_open()){ MessageBox(WindowHandle, "Failed to open FONTDATA, loading defaults.", NULL, NULL); fontheight=16; fontwidth=8; } else { getline(fin, typeface); typeface_c= new char [typeface.size()+1]; strcpy (typeface_c, typeface.c_str()); fin >> fontwidth; fin >> fontheight; if ((fontwidth <= 4) || (fontheight <=4)){ MessageBox(WindowHandle, "Invalid font size specified!", NULL, NULL); fontheight=16; fontwidth=8; } } halfwidth=fontwidth / 2; halfheight=fontheight / 2; WindowWidth=80*fontwidth; WindowHeight=25*fontheight; WindowX=(GetSystemMetrics(SM_CXSCREEN) / 2)-WindowWidth/2; //center this WindowY=(GetSystemMetrics(SM_CYSCREEN) / 2)-WindowHeight/2; //sucker WinCreate(); //Create the actual window, register it, etc CheckMessages(); //Let the message queue handle setting up the window WindowDC = GetDC(WindowHandle); backbuffer = CreateCompatibleDC(WindowDC); ZeroMemory(&bmi, sizeof(BITMAPINFO)); bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth = WindowWidth; bmi.bmiHeader.biHeight = -WindowHeight; bmi.bmiHeader.biPlanes = 1; bmi.bmiHeader.biBitCount=8; bmi.bmiHeader.biCompression = BI_RGB; //store it in uncompressed bytes bmi.bmiHeader.biSizeImage = WindowWidth * WindowHeight * 1; bmi.bmiHeader.biClrUsed=16; //the number of colors in our palette bmi.bmiHeader.biClrImportant=16; //the number of colors in our palette backbit = CreateDIBSection(0, &bmi, DIB_RGB_COLORS, (void**)&dcbits, NULL, 0); DeleteObject(SelectObject(backbuffer, backbit));//load the buffer into DC int nResults = AddFontResourceExA("data\\termfont",FR_PRIVATE,NULL); if (nResults>0){ font = CreateFont(fontheight, fontwidth, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FF_MODERN, typeface_c); //Create our font } else { MessageBox(WindowHandle, "Failed to load default font, using FixedSys.", NULL, NULL); font = CreateFont(fontheight, fontwidth, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FF_MODERN, "FixedSys"); //Create our font } //FixedSys will be user-changable at some point in time?? SetBkMode(backbuffer, TRANSPARENT);//Transparent font backgrounds SelectObject(backbuffer, font);//Load our font into the DC // WindowCount=0; delete typeface_c; mainwin = newwin(25,80,0,0); return mainwin; //create the 'stdscr' window and return its ref };
static int window_init(WININFO *info, bool use_custom_pixel_format = false, int custom_pixel_format = 0) { unsigned int PixelFormat; DWORD dwExStyle, dwStyle; DEVMODE dmScreenSettings; RECT rec; WNDCLASS wc; ZeroMemory(&wc, sizeof(WNDCLASS)); wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WndProc; wc.hInstance = info->hInstance; wc.lpszClassName = info->wndclass; if (!RegisterClass(&wc)) return(0); if (info->full) { dmScreenSettings.dmSize = sizeof(DEVMODE); dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; dmScreenSettings.dmBitsPerPel = 24; dmScreenSettings.dmPelsWidth = XRES; dmScreenSettings.dmPelsHeight = YRES; if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) return(0); dwExStyle = WS_EX_APPWINDOW; dwStyle = WS_VISIBLE | WS_POPUP;// | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; ShowCursor(0); } else { dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; dwStyle = WS_VISIBLE | WS_CAPTION | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU; } rec.left = 0; rec.top = 0; rec.right = XRES; rec.bottom = YRES; AdjustWindowRect(&rec, dwStyle, 0); windowRect.left = 0; windowRect.top = 0; windowRect.right = XRES; windowRect.bottom = YRES; info->hWnd = CreateWindowEx(dwExStyle, wc.lpszClassName, "live coding", dwStyle, (GetSystemMetrics(SM_CXSCREEN) - rec.right + rec.left) >> 1, (GetSystemMetrics(SM_CYSCREEN) - rec.bottom + rec.top) >> 1, rec.right - rec.left, rec.bottom - rec.top, 0, 0, info->hInstance, 0); if (!info->hWnd) return(0); if (!(info->hDC = GetDC(info->hWnd))) return(0); if (!use_custom_pixel_format) { if (!(PixelFormat = ChoosePixelFormat(info->hDC, &pfd))) return(0); if (!SetPixelFormat(info->hDC, PixelFormat, &pfd)) return(0); } else { if (!SetPixelFormat(info->hDC, custom_pixel_format, &pfd)) return(0); } if (!(info->hRC = wglCreateContext(info->hDC))) return(0); if (!wglMakeCurrent(info->hDC, info->hRC)) return(0); return(1); }
Bool WInitRibbons( HINSTANCE inst ) { int i; WRibbonInfo = WAllocToolBarInfo( NUM_TOOLS ); WSORibbonInfo = WAllocToolBarInfo( NUM_SOTOOLS ); if( WRibbonInfo == NULL || WSORibbonInfo == NULL ) { return( FALSE ); } for( i = 0; i < NUM_TOOLS; i++ ) { if( WRibbonNames[i].up != NULL ) { WRibbonInfo->items[i].u.bmp = LoadBitmap( inst, WRibbonNames[i].up ); WRibbonInfo->items[i].id = WRibbonNames[i].menu_id; WRibbonInfo->items[i].flags = ITEM_DOWNBMP; if( WRibbonNames[i].down != NULL ) { WRibbonInfo->items[i].depressed = LoadBitmap( inst, WRibbonNames[i].down ); } else { WRibbonInfo->items[i].depressed = WRibbonInfo->items[i].u.bmp; } if( WRibbonNames[i].tip_id >= 0 ) { LoadString( inst, WRibbonNames[i].tip_id, WRibbonInfo->items[i].tip, MAX_TIP ); } else { WRibbonInfo->items[i].tip[0] = '\0'; } } else { WRibbonInfo->items[i].flags = ITEM_BLANK; WRibbonInfo->items[i].u.blank_space = WRibbonNames[i].menu_id; } } for( i = 0; i < NUM_SOTOOLS; i++ ) { if( WSORibbonNames[i].up != NULL ) { WSORibbonInfo->items[i].u.bmp = LoadBitmap( inst, WSORibbonNames[i].up ); WSORibbonInfo->items[i].id = WSORibbonNames[i].menu_id; WSORibbonInfo->items[i].flags = ITEM_DOWNBMP; if( WSORibbonNames[i].down != NULL ) { WSORibbonInfo->items[i].depressed = LoadBitmap( inst, WSORibbonNames[i].down ); } else { WSORibbonInfo->items[i].depressed = WSORibbonInfo->items[i].u.bmp; } if( WSORibbonNames[i].tip_id >= 0 ) { LoadString( inst, WSORibbonNames[i].tip_id, WSORibbonInfo->items[i].tip, MAX_TIP ); } else { WSORibbonInfo->items[i].tip[0] = '\0'; } } else { WSORibbonInfo->items[i].flags = ITEM_BLANK; WSORibbonInfo->items[i].u.blank_space = WSORibbonNames[i].menu_id; } } WRibbonInfo->dinfo.button_size.x = BUTTONX + BUTTON_PAD; WRibbonInfo->dinfo.button_size.y = BUTTONY + BUTTON_PAD; WRibbonInfo->dinfo.border_size.x = TOOL_BORDERX; WRibbonInfo->dinfo.border_size.y = TOOL_BORDERY; WRibbonInfo->dinfo.style = TOOLBAR_FIXED_STYLE; WRibbonInfo->dinfo.hook = WRibbonHook; WRibbonInfo->dinfo.helphook = WRibbonHelpHook; WRibbonInfo->dinfo.foreground = NULL; WRibbonInfo->dinfo.background = NULL; WRibbonInfo->dinfo.is_fixed = TRUE; WRibbonInfo->dinfo.use_tips = TRUE; WSORibbonInfo->dinfo.button_size.x = BUTTONX + BUTTON_PAD; WSORibbonInfo->dinfo.button_size.y = BUTTONY + BUTTON_PAD; WSORibbonInfo->dinfo.border_size.x = TOOL_BORDERX; WSORibbonInfo->dinfo.border_size.y = TOOL_BORDERY; WSORibbonInfo->dinfo.style = TOOLBAR_FIXED_STYLE; WSORibbonInfo->dinfo.hook = WRibbonHook; WSORibbonInfo->dinfo.helphook = WRibbonHelpHook; WSORibbonInfo->dinfo.foreground = NULL; WSORibbonInfo->dinfo.background = NULL; WSORibbonInfo->dinfo.is_fixed = TRUE; WSORibbonInfo->dinfo.use_tips = TRUE; WRibbonHeight = 2 * WRibbonInfo->dinfo.border_size.y + WRibbonInfo->dinfo.button_size.y + 2 * GetSystemMetrics( SM_CYBORDER ); WRibbonInfo->dinfo.area.bottom = WRibbonHeight; WSORibbonInfo->dinfo.area.bottom = WRibbonHeight; return( TRUE ); }
BOOL CALLBACK DlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static LPNMTTDISPINFO lpnmtdi; static PAINTSTRUCT ps; static RECT windowRect; static HDC hdc; switch (message) { case WM_DWMCOMPOSITIONCHANGED: ActivateGlass(hDlg); InvalidateRect(hDlg, NULL, true); break; case WM_ACTIVATE: ActivateGlass(hDlg); break; case WM_PAINT: hdc = OnPaint(hDlg, windowRect, hdc, ps, IDS_APP_TITLE); break; case WM_INITDIALOG: hInstance = (HINSTANCE) GetWindowLong (hDlg, GWL_HINSTANCE); // Set Icon hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); hIconSally = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_SALLY)); hIconWindow = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_MENU_WINDOW)); hIconConfig = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_MENU_CONFIG)); hIconApplication = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_PLUGIN_APPLICATION)); hIconLanguage = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_PLUGIN_LANGUAGE)); hIconTheme = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_PLUGIN_THEME)); hIconKeyboard = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON_PLUGIN_KEYBORD)); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIcon); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon); // Menu himl = ImageList_Create(16, 16, ILC_COLOR32, 6, 0); ImageList_SetBkColor(himl, CLR_NONE); ImageList_AddIcon(himl, hIconWindow); ImageList_AddIcon(himl, hIconConfig); ImageList_AddIcon(himl, hIconApplication); ImageList_AddIcon(himl, hIconTheme); ImageList_AddIcon(himl, hIconLanguage); ImageList_AddIcon(himl, hIconKeyboard); hMenuView.SetHWND(GetDlgItem (hDlg, IDC_LIST_MENU)); hMenuView.SetImageList(himl, LVSIL_SMALL); ListView_SetExtendedListViewStyle(hMenuView.GetHwnd(), LVS_EX_FULLROWSELECT | WS_EX_LTRREADING); hMenuView.InitListViewColumns(0, "Settings", 190); hMenuView.AddItem(0, 0, GetLocalisation(IDS_MENU_CONFIG, hInstance), 1, 0); hMenuView.AddItem(1, 0, GetLocalisation(IDS_MENU_APPLICATIONS, hInstance), 2, 2); hMenuView.AddItem(2, 0, GetLocalisation(IDS_MENU_THEMES, hInstance), 3, 3); hMenuView.AddItem(3, 0, GetLocalisation(IDS_MENU_LANGUAGES, hInstance), 4, 4); hMenuView.AddItem(4, 0, GetLocalisation(IDS_MENU_KEYBOARDS, hInstance), 5, 5); // Tabs hWndTabConfig = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_CONFIG), hDlg, DlgProcConfig); ShowWindow(hWndTabConfig, SW_HIDE); hWndTabPlugins = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_PLUGINS), hDlg, DlgProcPlugins); ShowWindow(hWndTabPlugins, SW_HIDE); hWndTabThemes = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_THEMES), hDlg, DlgProcThemes); ShowWindow(hWndTabThemes, SW_HIDE); hWndTabLanguages = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_LANGUAGES), hDlg, DlgProcLanguages); ShowWindow(hWndTabLanguages, SW_HIDE); hWndTabKeyboards = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG_KEYBOARDS), hDlg, DlgProcKeyboards); ShowWindow(hWndTabKeyboards, SW_HIDE); SelectMenu(0); hMenuView.SelectItem(0); break; case WM_NOTIFY: lpnmtdi = (LPNMTTDISPINFO) lParam; if (lpnmtdi->hdr.hwndFrom == hMenuView.GetHwnd()) { switch(lpnmtdi->hdr.code) { case LVN_ITEMCHANGED: LPNMLISTVIEW li; li = (LPNMLISTVIEW)lParam; if (li->uNewState != 3) break; case NM_CLICK: case NM_RCLICK: case NM_DBLCLK: case NM_RDBLCLK: SelectMenu(); break; } } break; case WM_SIZE: RECT windowRect; RECT menuViewRect; RECT tempViewRect; GetClientRect(hDlg, &windowRect); GetClientRect(hMenuView.GetHwnd(), &menuViewRect); MoveWindow(hMenuView.GetHwnd(), 7, TOP_BORDER_HEIGHT + 7, CONFIG_MENU_WIDTH - 7, windowRect.bottom - TOP_BORDER_HEIGHT - 14, TRUE); GetClientRect(hWndTabConfig, &tempViewRect); MoveWindow(hWndTabConfig, ((windowRect.right - CONFIG_MENU_WIDTH - tempViewRect.right) / 2) + CONFIG_MENU_WIDTH, ((windowRect.bottom - TOP_BORDER_HEIGHT - tempViewRect.bottom) / 2) + TOP_BORDER_HEIGHT, tempViewRect.right, tempViewRect.bottom, TRUE); MoveWindow(hWndTabPlugins, CONFIG_MENU_WIDTH, TOP_BORDER_HEIGHT, windowRect.right - CONFIG_MENU_WIDTH, windowRect.bottom - TOP_BORDER_HEIGHT, TRUE); MoveWindow(hWndTabThemes, CONFIG_MENU_WIDTH, TOP_BORDER_HEIGHT, windowRect.right - CONFIG_MENU_WIDTH, windowRect.bottom - TOP_BORDER_HEIGHT, TRUE); MoveWindow(hWndTabLanguages, CONFIG_MENU_WIDTH, TOP_BORDER_HEIGHT, windowRect.right - CONFIG_MENU_WIDTH, windowRect.bottom - TOP_BORDER_HEIGHT, TRUE); MoveWindow(hWndTabKeyboards, CONFIG_MENU_WIDTH, TOP_BORDER_HEIGHT, windowRect.right - CONFIG_MENU_WIDTH, windowRect.bottom - TOP_BORDER_HEIGHT, TRUE); SendMessage(hWndTabPlugins, WM_COMMAND, WM_SIZE, NULL); SendMessage(hWndTabThemes, WM_COMMAND, WM_SIZE, NULL); SendMessage(hWndTabLanguages, WM_COMMAND, WM_SIZE, NULL); SendMessage(hWndTabKeyboards, WM_COMMAND, WM_SIZE, NULL); break; case WM_COMMAND: switch (LOWORD (wParam)) { case IDCANCEL: EndDialog (hDlg, 0); return TRUE; } break; case WM_GETMINMAXINFO: LPMINMAXINFO(lParam)->ptMinTrackSize.x = 750; // kleinste Breite LPMINMAXINFO(lParam)->ptMinTrackSize.y = 520; // kleinste Höhe return 0; case WM_NCHITTEST: LRESULT lresult; lresult = DefWindowProc(hDlg, WM_NCHITTEST, wParam, lParam); if (lresult == HTCLIENT) { GetWindowRect(hDlg, &windowRect); int yPos; yPos = GET_Y_LPARAM(lParam); yPos = yPos - windowRect.top - GetSystemMetrics(SM_CYSIZE) - GetSystemMetrics(SM_CYBORDER); if (yPos <= TOP_BORDER_HEIGHT) lresult = HTCAPTION; } SetWindowLong( hDlg, DWL_MSGRESULT, lresult ); return (TRUE); } return FALSE ; }
bool csGraphics2DOpenGL::Open () { if (is_open) return true; csRef<iVerbosityManager> verbosemgr ( csQueryRegistry<iVerbosityManager> (object_reg)); if (verbosemgr) detector.SetVerbose (verbosemgr->Enabled ("renderer.windows.gldriver")); // create the window. if (FullScreen) { SwitchDisplayMode (false); } int pixelFormat = -1; csGLPixelFormatPicker picker (this); /* Check if the WGL pixel format check should be used at all. It appears that some drivers take "odd" choices when using the WGL pixel format path (e.g. returning Accum-capable formats even if none was requested). */ bool doWGLcheck = false; { GLPixelFormat format; if (picker.GetNextFormat (format)) { doWGLcheck = (format[glpfvMultiSamples] != 0); picker.Reset (); } } if (doWGLcheck) pixelFormat = FindPixelFormatWGL (picker); m_bActivated = true; int wwidth = fbWidth; int wheight = fbHeight; DWORD exStyle = 0; DWORD style = WS_POPUP | WS_SYSMENU; int xpos = 0; int ypos = 0; if (FullScreen) { /*exStyle |= WS_EX_TOPMOST;*/ } else { style |= WS_CAPTION | WS_MINIMIZEBOX; if (AllowResizing) style |= WS_THICKFRAME | WS_MAXIMIZEBOX; wwidth += 2 * GetSystemMetrics (SM_CXFIXEDFRAME); wheight += 2 * GetSystemMetrics (SM_CYFIXEDFRAME) + GetSystemMetrics (SM_CYCAPTION); xpos = (GetSystemMetrics (SM_CXSCREEN) - wwidth) / 2; ypos = (GetSystemMetrics (SM_CYSCREEN) - wheight) / 2; } m_hWnd = m_piWin32Assistant->CreateCSWindow (this, exStyle, style, xpos, ypos, wwidth, wheight); if (!m_hWnd) SystemFatalError (L"Cannot create Crystal Space window", GetLastError()); SetTitle (win_title); // Subclass the window if (IsWindowUnicode (m_hWnd)) { m_OldWndProc = (WNDPROC)SetWindowLongPtrW (m_hWnd, GWLP_WNDPROC, (LONG_PTR) WindowProc); SetWindowLongPtrW (m_hWnd, GWLP_USERDATA, (LONG_PTR)this); } else { m_OldWndProc = (WNDPROC)SetWindowLongPtrA (m_hWnd, GWLP_WNDPROC, (LONG_PTR) WindowProc); SetWindowLongPtrA (m_hWnd, GWLP_USERDATA, (LONG_PTR)this); } hDC = GetDC (m_hWnd); if (pixelFormat == -1) { picker.Reset(); pixelFormat = FindPixelFormatGDI (hDC, picker); } PIXELFORMATDESCRIPTOR pfd; if (DescribePixelFormat (hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd) == 0) SystemFatalError (L"DescribePixelFormat failed.", GetLastError()); if (SetPixelFormat (hDC, pixelFormat, &pfd) != TRUE) { HRESULT spfErr = (HRESULT)GetLastError(); SystemFatalError (L"SetPixelFormat failed.", spfErr); } currentFormat[glpfvColorBits] = pfd.cColorBits; currentFormat[glpfvAlphaBits] = pfd.cAlphaBits; currentFormat[glpfvDepthBits] = pfd.cDepthBits; currentFormat[glpfvStencilBits] = pfd.cStencilBits; currentFormat[glpfvAccumColorBits] = pfd.cAccumBits; currentFormat[glpfvAccumAlphaBits] = pfd.cAccumAlphaBits; Depth = pfd.cColorBits; hardwareAccelerated = !(pfd.dwFlags & PFD_GENERIC_FORMAT) || (pfd.dwFlags & PFD_GENERIC_ACCELERATED); hGLRC = wglCreateContext (hDC); wglMakeCurrent (hDC, hGLRC); UpdateWindow (m_hWnd); ShowWindow (m_hWnd, m_nCmdShow); SetForegroundWindow (m_hWnd); SetFocus (m_hWnd); /* Small hack to emit "no HW acceleration" message on both GDI Generic and * sucky Direct3D default OpenGL */ hardwareAccelerated &= (strncmp ((char*)glGetString (GL_VENDOR), "Microsoft", 9) != 0); if (!hardwareAccelerated) { Report (CS_REPORTER_SEVERITY_WARNING, "No hardware acceleration!"); } detector.DoDetection (m_hWnd, hDC); Report (CS_REPORTER_SEVERITY_NOTIFY, "GL driver: %s %s", detector.GetDriverDLL(), detector.GetDriverVersion() ? detector.GetDriverVersion() : "<version unknown>"); if (FullScreen) { /* * from the Windows Shell docs: * "It is possible to cover the taskbar by explicitly setting the size * of the window rectangle equal to the size of the screen with * SetWindowPos." */ SetWindowPos (m_hWnd, CS_WINDOW_Z_ORDER, 0, 0, fbWidth, fbHeight, 0); } if (!csGraphics2DGLCommon::Open ()) return false; ext.InitWGL_EXT_swap_control (hDC); if (ext.CS_WGL_EXT_swap_control) { ext.wglSwapIntervalEXT (vsync ? 1 : 0); vsync = (ext.wglGetSwapIntervalEXT() != 0); Report (CS_REPORTER_SEVERITY_NOTIFY, "VSync is %s.", vsync ? "enabled" : "disabled"); } return true; }
INT_PTR CALLBACK DlgLuaScriptDialog(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { RECT r; RECT r2; int dx1, dy1, dx2, dy2; switch (msg) { case WM_INITDIALOG: { // remove the 30000 character limit from the console control SendMessage(GetDlgItem(hDlg, IDC_LUACONSOLE), EM_LIMITTEXT, 0, 0); //GetWindowRect(GetParent(hDlg), &r); GetWindowRect(gApp.hWnd, &r); dx1 = (r.right - r.left) / 2; dy1 = (r.bottom - r.top) / 2; GetWindowRect(hDlg, &r2); dx2 = (r2.right - r2.left) / 2; dy2 = (r2.bottom - r2.top) / 2; int windowIndex = 0;//std::find(LuaScriptHWnds.begin(), LuaScriptHWnds.end(), hDlg) - LuaScriptHWnds.begin(); int staggerOffset = windowIndex * 24; r.left += staggerOffset; r.right += staggerOffset; r.top += staggerOffset; r.bottom += staggerOffset; // push it away from the main window if we can const int width = (r.right - r.left); const int width2 = (r2.right - r2.left); if (r.left + width2 + width < GetSystemMetrics(SM_CXSCREEN)) { r.right += width; r.left += width; } else if ((int)r.left - (int)width2 > 0) { r.right -= width2; r.left -= width2; } SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); RECT r3; GetClientRect(hDlg, &r3); windowInfo.width = r3.right - r3.left; windowInfo.height = r3.bottom - r3.top; for (int i = 0; i < numControlLayoutInfos; i++) { ControlLayoutState& layoutState = windowInfo.layoutState[i]; layoutState.valid = false; } DragAcceptFiles(hDlg, true); SetDlgItemText(hDlg, IDC_EDIT_LUAPATH, PCSX2GetLuaScriptName()); SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &LuaConsoleLogFont, 0); // reset with an acceptable font LuaConsoleHWnd = GetDlgItem(hDlg, IDC_LUACONSOLE); consoleputstring.clear(); consoleputstring.reserve(250000); return true; } break; case WM_SIZE: { // resize or move controls in the window as necessary when the window is resized //LuaPerWindowInfo& windowInfo = LuaWindowInfo[hDlg]; int prevDlgWidth = windowInfo.width; int prevDlgHeight = windowInfo.height; int dlgWidth = LOWORD(lParam); int dlgHeight = HIWORD(lParam); int deltaWidth = dlgWidth - prevDlgWidth; int deltaHeight = dlgHeight - prevDlgHeight; for (int i = 0; i < numControlLayoutInfos; i++) { ControlLayoutInfo layoutInfo = controlLayoutInfos[i]; ControlLayoutState& layoutState = windowInfo.layoutState[i]; HWND hCtrl = GetDlgItem(hDlg, layoutInfo.controlID); int x, y, width, height; if (layoutState.valid) { x = layoutState.x; y = layoutState.y; width = layoutState.width; height = layoutState.height; } else { RECT r; GetWindowRect(hCtrl, &r); POINT p = { r.left, r.top }; ScreenToClient(hDlg, &p); x = p.x; y = p.y; width = r.right - r.left; height = r.bottom - r.top; } switch (layoutInfo.horizontalLayout) { case ControlLayoutInfo::RESIZE_END: width += deltaWidth; break; case ControlLayoutInfo::MOVE_START: x += deltaWidth; break; default: break; } switch (layoutInfo.verticalLayout) { case ControlLayoutInfo::RESIZE_END: height += deltaHeight; break; case ControlLayoutInfo::MOVE_START: y += deltaHeight; break; default: break; } SetWindowPos(hCtrl, 0, x, y, width, height, 0); layoutState.x = x; layoutState.y = y; layoutState.width = width; layoutState.height = height; layoutState.valid = true; } windowInfo.width = dlgWidth; windowInfo.height = dlgHeight; RedrawWindow(hDlg, NULL, NULL, RDW_INVALIDATE); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: { EndDialog(hDlg, true); // goto case WM_CLOSE; } break; case IDC_BUTTON_LUARUN: { if (!g_ReturnToGui) { consoleputstring.clear(); char filename[MAX_PATH]; GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH); if(PCSX2LoadLuaCode(filename)) WinLuaOnStart(); } } break; case IDC_BUTTON_LUASTOP: { PCSX2LuaStop(); WinLuaOnStop(); } break; case IDC_BUTTON_LUAEDIT: { char Str_Tmp[1024]; SendDlgItemMessage(hDlg, IDC_EDIT_LUAPATH, WM_GETTEXT, (WPARAM)512, (LPARAM)Str_Tmp); // tell the OS to open the file with its associated editor, // without blocking on it or leaving a command window open. if ((int)ShellExecute(NULL, "edit", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC) if ((int)ShellExecute(NULL, "open", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC) ShellExecute(NULL, NULL, "notepad", Str_Tmp, NULL, SW_SHOWNORMAL); } break; case IDC_BUTTON_LUABROWSE: { //systemSoundClearBuffer(); //CString filter = winResLoadFilter(IDS_FILTER_LUA); //CString title = winResLoadString(IDS_SELECT_LUA_NAME); //CString luaName = winGetDestFilename(theApp.gameFilename, IDS_LUA_DIR, ".lua"); //CString luaDir = winGetDestDir(IDS_LUA_DIR); //filter.Replace('|', '\000'); // char *p = filter.GetBuffer(0); // while ((p = strchr(p, '|')) != NULL) // *p++ = 0; char filenamebuffer[MAX_PATH]; ZeroMemory(filenamebuffer, MAX_PATH); OPENFILENAME ofn; ZeroMemory((LPVOID)&ofn, sizeof(OPENFILENAME)); ofn.lpstrFile = filenamebuffer; ofn.nMaxFile = MAX_PATH; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hDlg; ofn.lpstrFilter = "Lua Script(*.lua)\0*.lua\0All files(*.*)\0*.*\0\0"; ofn.nFilterIndex = 0; //ofn.lpstrInitialDir = ""; ofn.lpstrTitle = "choose lua file"; ofn.lpstrDefExt = "lua"; ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ENABLESIZING | OFN_EXPLORER; // hide previously-ignored read-only checkbox (the real read-only box is in the open-movie dialog itself) if (GetOpenFileName(&ofn)) { SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), filenamebuffer); } return true; } break; case IDC_EDIT_LUAPATH: { char filename[MAX_PATH]; GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH); FILE* file = fopen(filename, "rb"); EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUAEDIT), file != NULL); if (file) fclose(file); } break; case IDC_LUACONSOLE_CHOOSEFONT: { CHOOSEFONT cf; ZeroMemory(&cf, sizeof(cf)); cf.lStructSize = sizeof(CHOOSEFONT); cf.hwndOwner = hDlg; cf.lpLogFont = &LuaConsoleLogFont; cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT; if (ChooseFont(&cf)) { if (hFont) { DeleteObject(hFont); hFont = NULL; } hFont = CreateFontIndirect(&LuaConsoleLogFont); if (hFont) SendDlgItemMessage(hDlg, IDC_LUACONSOLE, WM_SETFONT, (WPARAM)hFont, 0); } } break; case IDC_LUACONSOLE_CLEAR: { SetWindowText(GetDlgItem(hDlg, IDC_LUACONSOLE), ""); } break; case IDC_LUACONSOLE_UPDATE: { /*排他制御してやらないと、出力したい文字列が途切れたりしてしまうのです。。。*/ lockLuamutex(); if (!LuaConsoleHWnd || consoleputstring.empty()){ unlockLuamutex(); break; } HWND hConsole = LuaConsoleHWnd; int length = GetWindowTextLength(hConsole); if (length >= 250000) { // discard first half of text if it's getting too long SendMessage(hConsole, EM_SETSEL, 0, length / 2); SendMessage(hConsole, EM_REPLACESEL, false, (LPARAM)""); length = GetWindowTextLength(hConsole); } SendMessage(hConsole, EM_SETSEL, length, length); //LuaPerWindowInfo& info = LuaWindowInfo[hDlg]; { consoleputstring = Replace(consoleputstring, "\n", "\r\n"); SendMessage(hConsole, EM_REPLACESEL, false, (LPARAM)consoleputstring.c_str()); } consoleputstring.clear(); unlockLuamutex(); } break; } // switch (LOWORD(wParam)) break; case WM_CLOSE: { //SendMessage(hDlg, WM_DESTROY, 0, 0); DestroyWindow(hDmyWnd); } break; case WM_DESTROY: { PCSX2LuaStop(); DragAcceptFiles(hDlg, FALSE); if (hFont) { DeleteObject(hFont); hFont = NULL; } LuaConsoleHWnd = NULL; hLuaDlg = NULL; hDmyWnd = NULL; } break; case WM_DROPFILES: { HDROP hDrop; //UINT fileNo; UINT fileCount; char filename[_MAX_PATH]; hDrop = (HDROP)wParam; fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0); if (fileCount > 0) { DragQueryFile(hDrop, 0, filename, sizeof(filename)); SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), filename); } DragFinish(hDrop); return true; } break; } return false; }
CStdString CSysInfo::GetKernelVersion() { #if defined(TARGET_DARWIN) return g_sysinfo.GetUnameVersion(); #elif defined (TARGET_POSIX) struct utsname un; if (uname(&un)==0) { CStdString strKernel; strKernel.Format("%s %s %s %s", un.sysname, un.release, un.version, un.machine); return strKernel; } return ""; #else OSVERSIONINFOEX osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(osvi); std::string strKernel = "Windows"; if (GetVersionEx((OSVERSIONINFO *)&osvi)) { switch (GetWindowsVersion()) { case WindowsVersionWinXP: if (GetSystemMetrics(SM_SERVERR2)) strKernel.append(" Server 2003 R2"); else if (osvi.wSuiteMask & VER_SUITE_STORAGE_SERVER) strKernel.append(" Storage Server 2003"); else if (osvi.wSuiteMask & VER_SUITE_WH_SERVER) strKernel.append(" Home Server"); else if (osvi.wProductType == VER_NT_WORKSTATION && IsOS64bit()) strKernel.append(" XP Professional"); else if (osvi.wProductType != VER_NT_WORKSTATION) strKernel.append(" Server 2003"); else if (osvi.wSuiteMask & VER_SUITE_PERSONAL) strKernel.append("XP Home Edition" ); else strKernel.append("XP Professional" ); break; case WindowsVersionVista: if (osvi.wProductType == VER_NT_WORKSTATION) strKernel.append(" Vista"); else strKernel.append(" Server 2008"); break; case WindowsVersionWin7: if (osvi.wProductType == VER_NT_WORKSTATION) strKernel.append(" 7"); else strKernel.append(" Server 2008 R2"); break; case WindowsVersionWin8: if (osvi.wProductType == VER_NT_WORKSTATION) strKernel.append(" 8"); else strKernel.append(" Server 2012"); break; case WindowsVersionFuture: strKernel.append(" Unknown Future Version"); break; default: strKernel.append(" Unknown version"); break; } // Append Service Pack version if any if (osvi.wServicePackMajor > 0) { strKernel.append(StringUtils::Format(" SP%d", osvi.wServicePackMajor)); if (osvi.wServicePackMinor > 0) { strKernel.append(StringUtils::Format(".%d", osvi.wServicePackMinor)); } } if (IsOS64bit()) strKernel.append(" 64-bit"); else strKernel.append(" 32-bit"); strKernel.append(StringUtils::Format(", build %d", osvi.dwBuildNumber)); } else { strKernel.append(" unknown"); if (IsOS64bit()) strKernel.append(" 64-bit"); else strKernel.append(" 32-bit"); } return strKernel; #endif }