INT_PTR WINAPI ConEmuAbout::aboutProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam) { INT_PTR lRc = 0; if (DonateBtns_Process(hDlg, messg, wParam, lParam, lRc) || EditIconHint_Process(hDlg, messg, wParam, lParam, lRc)) { SetWindowLongPtr(hDlg, DWLP_MSGRESULT, lRc); return TRUE; } PatchMsgBoxIcon(hDlg, messg, wParam, lParam); switch (messg) { case WM_INITDIALOG: { gpConEmu->OnOurDialogOpened(); mh_AboutDlg = hDlg; DonateBtns_Add(hDlg, pIconCtrl, IDOK); if (mp_DpiAware) { mp_DpiAware->Attach(hDlg, ghWnd, CDynDialog::GetDlgClass(hDlg)); } RECT rect = {}; if (GetWindowRect(hDlg, &rect)) { CDpiAware::GetCenteredRect(ghWnd, rect); MoveWindowRect(hDlg, rect); } if ((ghOpWnd && IsWindow(ghOpWnd)) || (WS_EX_TOPMOST & GetWindowLongPtr(ghWnd, GWL_EXSTYLE))) { SetWindowPos(hDlg, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE); } LPCWSTR pszActivePage = (LPCWSTR)lParam; wchar_t* pszTitle = lstrmerge(gpConEmu->GetDefaultTitle(), L" About"); if (pszTitle) { SetWindowText(hDlg, pszTitle); SafeFree(pszTitle); } if (hClassIcon) { SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hClassIcon); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)CreateNullIcon()); SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)hClassIcon); } SetDlgItemText(hDlg, stConEmuAbout, pAboutTitle); SetDlgItemText(hDlg, stConEmuUrl, gsHomePage); EditIconHint_Set(hDlg, GetDlgItem(hDlg, tAboutSearch), true, L"Search", false, UM_SEARCH, IDOK); EditIconHint_Subclass(hDlg); wchar_t* pszLabel = GetDlgItemTextPtr(hDlg, stConEmuVersion); if (pszLabel) { wchar_t* pszSet = NULL; if (gpUpd) { wchar_t* pszVerInfo = gpUpd->GetCurVerInfo(); if (pszVerInfo) { pszSet = lstrmerge(pszLabel, L" ", pszVerInfo); free(pszVerInfo); } } if (!pszSet) { pszSet = lstrmerge(pszLabel, L" ", L"Please check for updates manually"); } if (pszSet) { SetDlgItemText(hDlg, stConEmuVersion, pszSet); free(pszSet); } free(pszLabel); } HWND hTab = GetDlgItem(hDlg, tbAboutTabs); INT_PTR nPage = -1; for (size_t i = 0; i < countof(Pages); i++) { TCITEM tie = {}; tie.mask = TCIF_TEXT; tie.pszText = (LPWSTR)Pages[i].Title; TabCtrl_InsertItem(hTab, i, &tie); if (pszActivePage && (lstrcmpi(pszActivePage, Pages[i].Title) == 0)) nPage = i; } if (nPage >= 0) { TabSelected(hDlg, nPage); TabCtrl_SetCurSel(hTab, (int)nPage); } else if (!pszActivePage) { TabSelected(hDlg, 0); } else { _ASSERTE(pszActivePage==NULL && "Unknown page name?"); } SetFocus(hTab); return FALSE; } case WM_CTLCOLORSTATIC: if (GetWindowLongPtr((HWND)lParam, GWLP_ID) == stConEmuUrl) { SetTextColor((HDC)wParam, GetSysColor(COLOR_HOTLIGHT)); HBRUSH hBrush = GetSysColorBrush(COLOR_3DFACE); SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)hBrush; } else { SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); HBRUSH hBrush = GetSysColorBrush(COLOR_3DFACE); SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)hBrush; } break; case WM_SETCURSOR: { if (GetWindowLongPtr((HWND)wParam, GWLP_ID) == stConEmuUrl) { SetCursor(LoadCursor(NULL, IDC_HAND)); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE); return TRUE; } return FALSE; } break; case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: case IDCLOSE: aboutProc(hDlg, WM_CLOSE, 0, 0); return 1; case stConEmuUrl: ConEmuAbout::OnInfo_HomePage(); return 1; } // BN_CLICKED break; case EN_SETFOCUS: switch (LOWORD(wParam)) { case tAboutText: { // Do not autosel all text HWND hEdit = (HWND)lParam; DWORD nStart = 0, nEnd = 0; SendMessage(hEdit, EM_GETSEL, (WPARAM)&nStart, (LPARAM)&nEnd); if (nStart != nEnd) { SendMessage(hEdit, EM_SETSEL, nTextSelStart, nTextSelEnd); } } break; } } // switch (HIWORD(wParam)) break; case WM_NOTIFY: { LPNMHDR nmhdr = (LPNMHDR)lParam; if ((nmhdr->code == TCN_SELCHANGE) && (nmhdr->idFrom == tbAboutTabs)) { int iPage = TabCtrl_GetCurSel(nmhdr->hwndFrom); if ((iPage >= 0) && (iPage < (int)countof(Pages))) TabSelected(hDlg, iPage); } break; } case UM_SEARCH: searchProc(hDlg, (HWND)lParam, false); break; case UM_EDIT_KILL_FOCUS: SendMessage((HWND)lParam, EM_GETSEL, (WPARAM)&nTextSelStart, (LPARAM)&nTextSelEnd); break; case WM_CLOSE: //if (ghWnd == NULL) gpConEmu->OnOurDialogClosed(); if (mp_DpiAware) mp_DpiAware->Detach(); EndDialog(hDlg, IDOK); //else // DestroyWindow(hDlg); break; case WM_DESTROY: mh_AboutDlg = NULL; break; default: if (mp_DpiAware && mp_DpiAware->ProcessDpiMessages(hDlg, messg, wParam, lParam)) { return TRUE; } } return FALSE; }
// Общая DlgProc на _все_ вкладки INT_PTR CSetPgBase::pageOpProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam) { TabHwndIndex pgId = thi_Last; CSetPgBase* pObj = NULL; if (messg != WM_INITDIALOG) { ConEmuSetupPages* pPage = NULL; pgId = gpSetCls->GetPageId(hDlg, &pPage); if ((pgId == thi_Last) || !pPage || !pPage->pPage) { _ASSERTE(FALSE && "Page was not created properly yet"); return TRUE; } pObj = pPage->pPage; _ASSERTE(pObj && (pObj->mn_ActivateTabMsg != WM_APP)); if (!pObj) { return TRUE; } if (pObj && pObj->mp_DpiAware && pObj->mp_DpiAware->ProcessDpiMessages(hDlg, messg, wParam, lParam)) { return TRUE; } } if ((messg == WM_INITDIALOG) || (pObj && (messg == pObj->mn_ActivateTabMsg))) { bool bInitial = (messg == WM_INITDIALOG); if (bInitial) { if (!lParam) { _ASSERTE(lParam != 0); return 0; } pObj = (CSetPgBase*)lParam; } if (!pObj || (pObj->GetPageType() < thi_Fonts) || (pObj->GetPageType() >= thi_Last)) { _ASSERTE(pObj && (pObj->GetPageType() >= thi_Fonts && pObj->GetPageType() < thi_Last)); return 0; } _ASSERTE(pObj->Dlg() == NULL || pObj->Dlg() == hDlg); pgId = pObj->GetPageType(); if (bInitial) { _ASSERTE(pObj->mp_InfoPtr && pObj->mp_InfoPtr->PageIndex >= 0 && pObj->mp_InfoPtr->hPage == NULL); pObj->mp_InfoPtr->hPage = hDlg; pObj->mh_Dlg = hDlg; CDynDialog* pDynDialog = CDynDialog::GetDlgClass(hDlg); _ASSERTE(pObj->mp_DynDialog==NULL || pObj->mp_DynDialog==pDynDialog); #ifdef _DEBUG // pObj->mp_DynDialog is NULL on first WM_INIT if (pObj->mp_DynDialog) { _ASSERTE(pObj->mp_DynDialog->mh_Dlg == hDlg); } #endif HWND hPlace = GetDlgItem(pObj->mh_Parent, tSetupPagePlace); RECT rcClient; GetWindowRect(hPlace, &rcClient); MapWindowPoints(NULL, pObj->mh_Parent, (LPPOINT)&rcClient, 2); if (pObj->mp_DpiAware) pObj->mp_DpiAware->Attach(hDlg, pObj->mh_Parent, pDynDialog); MoveWindowRect(hDlg, rcClient); } else { _ASSERTE(pObj->mp_InfoPtr->PageIndex >= 0 && pObj->mp_InfoPtr->hPage == hDlg); } MSetter lockSelChange(&pObj->mb_SkipSelChange); pObj->OnInitDialog(hDlg, bInitial); if (bInitial) { EditIconHint_Subclass(hDlg, pObj->mh_Parent); gpSetCls->RegisterTipsFor(hDlg); } pObj->OnPostLocalize(hDlg); } else if ((messg == WM_HELP) || (messg == HELP_WM_HELP)) { _ASSERTE(messg == WM_HELP); return gpSetCls->wndOpProc(hDlg, messg, wParam, lParam); } else if (pgId == thi_Apps) { // Страничка "App distinct" в некотором смысле особенная. // У многих контролов ИД дублируются с другими вкладками. CSetPgApps* pAppsPg; if (gpSetCls->GetPageObj(pAppsPg)) { return pAppsPg->PageDlgProc(hDlg, messg, wParam, lParam); } else { _ASSERTE(pAppsPg!=NULL); return 0; } } else if (pgId == thi_Integr) { return pObj->PageDlgProc(hDlg, messg, wParam, lParam); } else if (pgId == thi_Startup) { return pObj->PageDlgProc(hDlg, messg, wParam, lParam); } else // All other messages switch (messg) { #ifdef _DEBUG case WM_INITDIALOG: // Должно быть обработано выше _ASSERTE(messg != WM_INITDIALOG); break; #endif case WM_COMMAND: { switch (HIWORD(wParam)) { case BN_CLICKED: return CSetDlgButtons::OnButtonClicked(hDlg, wParam, lParam); case EN_CHANGE: // TODO: Remove duplicate condition! if (!pObj->mb_SkipSelChange && !pObj->mb_IgnoreEditChanged) pObj->OnEditChanged(hDlg, LOWORD(wParam)); return 0; case CBN_EDITCHANGE: case CBN_SELCHANGE/*LBN_SELCHANGE*/: if (!pObj->mb_SkipSelChange) pObj->OnComboBox(hDlg, LOWORD(wParam), HIWORD(wParam)); return 0; case LBN_DBLCLK: gpSetCls->OnListBoxDblClk(hDlg, wParam, lParam); return 0; case CBN_KILLFOCUS: if (gpSetCls->mn_LastChangingFontCtrlId && (LOWORD(wParam) == gpSetCls->mn_LastChangingFontCtrlId)) { _ASSERTE(pgId == thi_Fonts); PostMessage(hDlg, gpSetCls->mn_MsgRecreateFont, gpSetCls->mn_LastChangingFontCtrlId, 0); gpSetCls->mn_LastChangingFontCtrlId = 0; return 0; } break; default: if (HIWORD(wParam) == 0xFFFF && LOWORD(wParam) == lbConEmuHotKeys) { dynamic_cast<CSetPgKeys*>(pObj)->OnHotkeysNotify(hDlg, wParam, 0); } } // switch (HIWORD(wParam)) } // WM_COMMAND break; case WM_MEASUREITEM: return gpSetCls->OnMeasureFontItem(hDlg, messg, wParam, lParam); case WM_DRAWITEM: return gpSetCls->OnDrawFontItem(hDlg, messg, wParam, lParam); case WM_CTLCOLORSTATIC: return pObj->OnCtlColorStatic(hDlg, (HDC)wParam, (HWND)lParam, GetDlgCtrlID((HWND)lParam)); case WM_SETCURSOR: return pObj->OnSetCursor(hDlg, (HWND)wParam, GetDlgCtrlID((HWND)wParam), LOWORD(lParam), HIWORD(lParam)); case WM_HSCROLL: { if ((pgId == thi_Backgr) && (HWND)lParam == GetDlgItem(hDlg, slDarker)) { int newV = SendDlgItemMessage(hDlg, slDarker, TBM_GETPOS, 0, 0); if (newV != gpSet->bgImageDarker) { gpSetCls->SetBgImageDarker(newV, true); //gpSet->bgImageDarker = newV; //TCHAR tmp[10]; //_wsprintf(tmp, SKIPLEN(countof(tmp)) L"%i", gpSet->bgImageDarker); //SetDlgItemText(hDlg, tDarker, tmp); //// Картинку может установить и плагин //if (gpSet->isShowBgImage && gpSet->sBgImage[0]) // gpSetCls->LoadBackgroundFile(gpSet->sBgImage); //else // gpSetCls->NeedBackgroundUpdate(); //gpConEmu->Update(true); } } else if ((pgId == thi_Transparent) && (HWND)lParam == GetDlgItem(hDlg, slTransparent)) { int newV = SendDlgItemMessage(hDlg, slTransparent, TBM_GETPOS, 0, 0); if (newV != gpSet->nTransparent) { CSettings::checkDlgButton(hDlg, cbTransparent, (newV != MAX_ALPHA_VALUE) ? BST_CHECKED : BST_UNCHECKED); gpSet->nTransparent = newV; if (!gpSet->isTransparentSeparate) SendDlgItemMessage(hDlg, slTransparentInactive, TBM_SETPOS, (WPARAM)true, (LPARAM)gpSet->nTransparent); gpConEmu->OnTransparent(); } } else if ((pgId == thi_Transparent) && (HWND)lParam == GetDlgItem(hDlg, slTransparentInactive)) { int newV = SendDlgItemMessage(hDlg, slTransparentInactive, TBM_GETPOS, 0, 0); if (gpSet->isTransparentSeparate && (newV != gpSet->nTransparentInactive)) { //checkDlgButton(hDlg, cbTransparentInactive, (newV!=MAX_ALPHA_VALUE) ? BST_CHECKED : BST_UNCHECKED); gpSet->nTransparentInactive = newV; gpConEmu->OnTransparent(); } } } // WM_HSCROLL break; case WM_NOTIFY: { if (((NMHDR*)lParam)->code == TTN_GETDISPINFO) { return gpSetCls->ProcessTipHelp(hDlg, messg, wParam, lParam); } else switch (((NMHDR*)lParam)->idFrom) { case lbActivityLog: if (!pObj->mb_SkipSelChange) return gpSetCls->OnActivityLogNotify(hDlg, wParam, lParam); break; case lbConEmuHotKeys: if (!pObj->mb_SkipSelChange) return dynamic_cast<CSetPgKeys*>(pObj)->OnHotkeysNotify(hDlg, wParam, lParam); break; } return 0; } // WM_NOTIFY break; case WM_TIMER: if (wParam == BALLOON_MSG_TIMERID) { KillTimer(hDlg, BALLOON_MSG_TIMERID); SendMessage(gpSetCls->hwndBalloon, TTM_TRACKACTIVATE, FALSE, (LPARAM)&gpSetCls->tiBalloon); SendMessage(gpSetCls->hwndTip, TTM_ACTIVATE, TRUE, 0); } break; default: { if (messg == gpSetCls->mn_MsgRecreateFont) { gpSetCls->RecreateFont(LOWORD(wParam)); } else if (messg == gpSetCls->mn_MsgLoadFontFromMain) { CSetPgFonts* pFonts = NULL; if (gpSetCls->GetPageObj(pFonts)) { if (pgId == thi_Views) pFonts->CopyFontsTo(hDlg, tThumbsFontName, tTilesFontName, 0); else if (pgId == thi_Tabs) pFonts->CopyFontsTo(hDlg, tTabFontFace, 0); else if (pgId == thi_Status) pFonts->CopyFontsTo(hDlg, tStatusFontFace, 0); } } else if (messg == gpSetCls->mn_MsgUpdateCounter) { gpSetCls->PostUpdateCounters(true); } else if (messg == DBGMSG_LOG_ID && pgId == thi_Debug) { MSetter lockSelChange(&pObj->mb_SkipSelChange); if (wParam == DBGMSG_LOG_SHELL_MAGIC) { DebugLogShellActivity *pShl = (DebugLogShellActivity*)lParam; gpSetCls->debugLogShell(hDlg, pShl); } // DBGMSG_LOG_SHELL_MAGIC else if (wParam == DBGMSG_LOG_INPUT_MAGIC) { CESERVER_REQ_PEEKREADINFO* pInfo = (CESERVER_REQ_PEEKREADINFO*)lParam; gpSetCls->debugLogInfo(hDlg, pInfo); } // DBGMSG_LOG_INPUT_MAGIC else if (wParam == DBGMSG_LOG_CMD_MAGIC) { CSettings::LogCommandsData* pCmd = (CSettings::LogCommandsData*)lParam; gpSetCls->debugLogCommand(hDlg, pCmd); } // DBGMSG_LOG_CMD_MAGIC } // if (messg == DBGMSG_LOG_ID && hDlg == gpSetCls->hDebug) else { pObj->PageDlgProc(hDlg, messg, wParam, lParam); } } // default: } //switch (messg) return 0; }