Пример #1
0
LRESULT CSetPgStatus::OnInitDialog(HWND hDlg, bool abInitial)
{
	SetDlgItemText(hDlg, tStatusFontFace, gpSet->sStatusFontFace);

	if (CSetDlgFonts::EnumFontsFinished())  // Если шрифты уже считаны
	{
		CSetPgFonts* pFonts = NULL;
		if (gpSetCls->GetPageObj(pFonts))
		{
			pFonts->CopyFontsTo(hDlg, tStatusFontFace, 0); // можно скопировать список с вкладки [thi_Fonts]
		}
	}

	UINT nVal = gpSet->nStatusFontHeight;
	CSetDlgLists::FillListBoxItems(GetDlgItem(hDlg, tStatusFontHeight), CSetDlgLists::eFSizesSmall, nVal, true);

	CSetDlgLists::FillListBoxItems(GetDlgItem(hDlg, tStatusFontCharset), CSetDlgLists::eCharSets, gpSet->nStatusFontCharSet, false);

	// Colors
	for (uint c = c35; c <= c37; c++)
		CSetDlgColors::ColorSetEdit(hDlg, c);

	checkDlgButton(hDlg, cbStatusVertSep, (gpSet->isStatusBarFlags & csf_VertDelim) ? BST_CHECKED : BST_UNCHECKED);
	checkDlgButton(hDlg, cbStatusHorzSep, (gpSet->isStatusBarFlags & csf_HorzDelim) ? BST_CHECKED : BST_UNCHECKED);
	checkDlgButton(hDlg, cbStatusVertPad, (gpSet->isStatusBarFlags & csf_NoVerticalPad)==0 ? BST_CHECKED : BST_UNCHECKED);
	checkDlgButton(hDlg, cbStatusSystemColors, (gpSet->isStatusBarFlags & csf_SystemColors) ? BST_CHECKED : BST_UNCHECKED);

	CSetDlgLists::EnableDlgItems(hDlg, CSetDlgLists::eStatusColorIds, !(gpSet->isStatusBarFlags & csf_SystemColors));

	checkDlgButton(hDlg, cbShowStatusBar, gpSet->isStatusBarShow);

	//for (size_t i = 0; i < countof(SettingsNS::StatusItems); i++)
	//{
	//	checkDlgButton(hDlg, SettingsNS::StatusItems[i].nDlgID, !gpSet->isStatusColumnHidden[SettingsNS::StatusItems[i].stItem]);
	//}

	UpdateStatusItems(hDlg);

	return 0;
}
Пример #2
0
// Общая 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;
}