// Function GetConsoleSelectionInfo does NOT exists in Windows 2000 // The function is used ONLY for checking if console is "Paused", // because when selection is present - StdOut is placed in "halt" state BOOL apiGetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo) { typedef BOOL (WINAPI* GetConsoleSelectionInfo_t)(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo); static GetConsoleSelectionInfo_t getConsoleSelectionInfo = NULL; static bool bFuncChecked = false; if (!bFuncChecked) { HMODULE hKernel32 = GetModuleHandle(L"kernel32.dll"); getConsoleSelectionInfo = hKernel32 ? (GetConsoleSelectionInfo_t)GetProcAddress(hKernel32, "GetConsoleSelectionInfo") : NULL; bFuncChecked = true; } BOOL bRc = FALSE; if (getConsoleSelectionInfo) { bRc = getConsoleSelectionInfo(lpConsoleSelectionInfo); } else if (IsWin2kEql()) // Otherwise, that might be Windows 2000 { // We can't be sure, but if cursor height is 100% it will be selection most probably bool bProbableSelection = false; CONSOLE_CURSOR_INFO ci = {}; if (gbPauseConsoleWasRequested) { bRc = GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &ci); if (bRc && (ci.dwSize == 100)) { bProbableSelection = true; } } memset(lpConsoleSelectionInfo, sizeof(*lpConsoleSelectionInfo), 0); if (bProbableSelection) { lpConsoleSelectionInfo->dwFlags = CONSOLE_SELECTION_IN_PROGRESS; } } else { _ASSERTE(FALSE && "GetConsoleSelectionInfo was not found!"); } return bRc; }
static INT_PTR Fast_OnInitDialog(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam) { SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hClassIcon); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hClassIconSm); if (gp_DpiAware) { gp_DpiAware->Attach(hDlg, NULL, CDynDialog::GetDlgClass(hDlg)); } RECT rect = {}; if (GetWindowRect(hDlg, &rect)) { CDpiAware::GetCenteredRect(NULL, rect); MoveWindowRect(hDlg, rect); } if (lParam) { SetWindowText(hDlg, (LPCWSTR)lParam); } else { wchar_t szTitle[512]; wcscpy_c(szTitle, gpConEmu->GetDefaultTitle()); wcscat_c(szTitle, L" fast configuration"); SetWindowText(hDlg, szTitle); } // lbStorageLocation SettingsStorage Storage = {}; bool ReadOnly = false; gpSet->GetSettingsType(Storage, ReadOnly); // Same priority as in CConEmuMain::ConEmuXml (reverse order) wchar_t* pszSettingsPlaces[] = { lstrdup(L"HKEY_CURRENT_USER\\Software\\ConEmu"), ExpandEnvStr(L"%APPDATA%\\ConEmu.xml"), ExpandEnvStr(L"%ConEmuBaseDir%\\ConEmu.xml"), ExpandEnvStr(L"%ConEmuDir%\\ConEmu.xml"), NULL }; // Lets find first allowed item int iAllowed = 0; if (lstrcmp(Storage.szType, CONEMU_CONFIGTYPE_XML) == 0) { iAllowed = 1; // XML is used, registry is not allowed if (Storage.pszFile) { if (lstrcmpi(Storage.pszFile, pszSettingsPlaces[1]) == 0) // %APPDATA% iAllowed = 1; // Any other xml has greater priority else if (lstrcmpi(Storage.pszFile, pszSettingsPlaces[2]) == 0) // %ConEmuBaseDir% iAllowed = 2; // Only %ConEmuDir% has greater priority else if (lstrcmpi(Storage.pszFile, pszSettingsPlaces[3]) == 0) // %ConEmuDir% iAllowed = 3; // Most prioritized else { // Directly specified with "/LoadCfgFile ..." SafeFree(pszSettingsPlaces[3]); pszSettingsPlaces[3] = lstrdup(Storage.pszFile); iAllowed = 3; // Most prioritized } } } // Index of the default location (relative to listbox, but not a pszSettingsPlaces) // By default - suggest %APPDATA% or, if possible, %ConEmuDir% // Win2k does not have 'msxml3.dll'/'msxml3r.dll' libraries int iDefault = ((iAllowed == 0) && !IsWin2kEql()) ? (CConEmuUpdate::NeedRunElevation() ? 1 : 3) : 0; // Populate lbStorageLocation while (pszSettingsPlaces[iAllowed]) { SendDlgItemMessage(hDlg, lbStorageLocation, CB_ADDSTRING, 0, (LPARAM)pszSettingsPlaces[iAllowed]); iAllowed++; } SendDlgItemMessage(hDlg, lbStorageLocation, CB_SETCURSEL, iDefault, 0); // Release memory for (int i = 0; pszSettingsPlaces[i]; i++) { SafeFree(pszSettingsPlaces[i]); } // Tasks const CommandTasks* pGrp = NULL; for (int nGroup = 0; (pGrp = gpSet->CmdTaskGet(nGroup)) != NULL; nGroup++) { SendDlgItemMessage(hDlg, lbStartupShellFast, CB_ADDSTRING, 0, (LPARAM)pGrp->pszName); } // Show startup task or shell command line LPCWSTR pszStartup = (gpSet->nStartType == 2) ? gpSet->psStartTasksName : (gpSet->nStartType == 0) ? gpSet->psStartSingleApp : NULL; if (pszStartup && *pszStartup) CSetDlgLists::SelectStringExact(hDlg, lbStartupShellFast, pszStartup); // Palettes (console color sets) const ColorPalette* pPal = NULL; for (int nPal = 0; (pPal = gpSet->PaletteGet(nPal)) != NULL; nPal++) { SendDlgItemMessage(hDlg, lbColorSchemeFast, CB_ADDSTRING, 0, (LPARAM)pPal->pszName); } // Show active (default) palette gp_DefaultPalette = gpSet->PaletteFindCurrent(true); if (gp_DefaultPalette) { CSetDlgLists::SelectStringExact(hDlg, lbColorSchemeFast, gp_DefaultPalette->pszName); } else { _ASSERTE(FALSE && "Current paletted was not defined?"); } // Show its colors in box HWND hChild = GetDlgItem(hDlg, stPalettePreviewFast); if (hChild) gpfn_DefaultColorBoxProc = (WNDPROC)SetWindowLongPtr(hChild, GWLP_WNDPROC, (LONG_PTR)Fast_ColorBoxProc); // Single instance CheckDlgButton(hDlg, cbSingleInstance, gpSetCls->IsSingleInstanceArg()); // Quake style and show/hide key CheckDlgButton(hDlg, cbQuakeFast, gpSet->isQuakeStyle ? BST_CHECKED : BST_UNCHECKED); const ConEmuHotKey* pHK = NULL; if (gpSet->GetHotkeyById(vkMinimizeRestore, &pHK) && pHK) { wchar_t szKey[128] = L""; SetDlgItemText(hDlg, tQuakeKeyFast, pHK->GetHotkeyName(szKey)); ghk_MinMaxKey.SetVkMod(pHK->GetVkMod()); } // Keyhooks required for Win+Number, Win+Arrows, etc. CheckDlgButton(hDlg, cbUseKeyboardHooksFast, gpSet->isKeyboardHooks(true)); // Debug purposes only. ConEmu.exe switch "/nokeyhooks" #ifdef _DEBUG EnableWindow(GetDlgItem(hDlg, cbUseKeyboardHooksFast), !gpConEmu->DisableKeybHooks); #endif // Injects CheckDlgButton(hDlg, cbInjectConEmuHkFast, gpSet->isUseInjects); // Autoupdates if (!gpConEmu->isUpdateAllowed()) { EnableWindow(GetDlgItem(hDlg, cbEnableAutoUpdateFast), FALSE); EnableWindow(GetDlgItem(hDlg, rbAutoUpdateStableFast), FALSE); EnableWindow(GetDlgItem(hDlg, rbAutoUpdatePreviewFast), FALSE); EnableWindow(GetDlgItem(hDlg, rbAutoUpdateDeveloperFast), FALSE); EnableWindow(GetDlgItem(hDlg, stEnableAutoUpdateFast), FALSE); } else { if (gpSet->UpdSet.isUpdateUseBuilds != 0) CheckDlgButton(hDlg, cbEnableAutoUpdateFast, gpSet->UpdSet.isUpdateCheckOnStartup|gpSet->UpdSet.isUpdateCheckHourly); CheckRadioButton(hDlg, rbAutoUpdateStableFast, rbAutoUpdateDeveloperFast, (gpSet->UpdSet.isUpdateUseBuilds == 1) ? rbAutoUpdateStableFast : (gpSet->UpdSet.isUpdateUseBuilds == 3) ? rbAutoUpdatePreviewFast : rbAutoUpdateDeveloperFast); } // Vista - ConIme bugs if (!bCheckIme) { ShowWindow(GetDlgItem(hDlg, gbDisableConImeFast), SW_HIDE); ShowWindow(GetDlgItem(hDlg, cbDisableConImeFast), SW_HIDE); ShowWindow(GetDlgItem(hDlg, stDisableConImeFast1), SW_HIDE); ShowWindow(GetDlgItem(hDlg, stDisableConImeFast2), SW_HIDE); ShowWindow(GetDlgItem(hDlg, stDisableConImeFast3), SW_HIDE); RECT rcGroup, rcBtn, rcWnd; if (GetWindowRect(GetDlgItem(hDlg, gbDisableConImeFast), &rcGroup)) { int nShift = (rcGroup.bottom-rcGroup.top); HWND h = GetDlgItem(hDlg, IDOK); GetWindowRect(h, &rcBtn); MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBtn, 2); SetWindowPos(h, NULL, rcBtn.left, rcBtn.top - nShift, 0,0, SWP_NOSIZE|SWP_NOZORDER); h = GetDlgItem(hDlg, IDCANCEL); GetWindowRect(h, &rcBtn); MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBtn, 2); SetWindowPos(h, NULL, rcBtn.left, rcBtn.top - nShift, 0,0, SWP_NOSIZE|SWP_NOZORDER); h = GetDlgItem(hDlg, stHomePage); GetWindowRect(h, &rcBtn); MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBtn, 2); SetWindowPos(h, NULL, rcBtn.left, rcBtn.top - nShift, 0,0, SWP_NOSIZE|SWP_NOZORDER); SetWindowText(h, gsHomePage); GetWindowRect(hDlg, &rcWnd); MoveWindow(hDlg, rcWnd.left, rcWnd.top+(nShift>>1), rcWnd.right-rcWnd.left, rcWnd.bottom-rcWnd.top-nShift, FALSE); }