/
makani
/
strongdc
Обзор
Документация
Войти
/
makani
/
strongdc
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
windows/GeneralPage.cpp
112 строк
3 KB
bigmuscle
updated client profiles URL
06 фев 2008, 20:23
06 фев 2008, 20:23
2dfe57e
Код
Авторство
О чём код?
/* * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "stdafx.h" #include "../client/DCPlusPlus.h" #include "../client/SettingsManager.h" #include "../client/Socket.h" #include "Resource.h" #include "GeneralPage.h" #include "WinUtil.h" PropPage::TextItem GeneralPage::texts[] = { { IDC_SETTINGS_PERSONAL_INFORMATION, ResourceManager::SETTINGS_PERSONAL_INFORMATION }, { IDC_SETTINGS_NICK, ResourceManager::NICK }, { IDC_SETTINGS_EMAIL, ResourceManager::EMAIL }, { IDC_SETTINGS_DESCRIPTION, ResourceManager::DESCRIPTION }, { IDC_SETTINGS_UPLOAD_LINE_SPEED, ResourceManager::SETTINGS_UPLOAD_LINE_SPEED }, { IDC_SETTINGS_MEBIBITS, ResourceManager::MBITSPS }, { 0, ResourceManager::SETTINGS_AUTO_AWAY } }; PropPage::Item GeneralPage::items[] = { { IDC_NICK, SettingsManager::NICK, PropPage::T_STR }, { IDC_EMAIL, SettingsManager::EMAIL, PropPage::T_STR }, { IDC_DESCRIPTION, SettingsManager::DESCRIPTION, PropPage::T_STR }, { IDC_CONNECTION, SettingsManager::UPLOAD_SPEED, PropPage::T_STR }, { 0, 0, PropPage::T_END } }; void GeneralPage::write() { PropPage::write((HWND)(*this), items); } LRESULT GeneralPage::onInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { PropPage::translate((HWND)(*this), texts); ctrlConnection.Attach(GetDlgItem(IDC_CONNECTION)); for(StringIter i = SettingsManager::connectionSpeeds.begin(); i != SettingsManager::connectionSpeeds.end(); ++i) ctrlConnection.AddString(Text::toT(*i).c_str()); PropPage::read((HWND)(*this), items); ctrlConnection.SetCurSel(ctrlConnection.FindString(0, Text::toT(SETTING(UPLOAD_SPEED)).c_str())); nick.Attach(GetDlgItem(IDC_NICK)); nick.LimitText(35); desc.Attach(GetDlgItem(IDC_DESCRIPTION)); desc.LimitText(35); desc.Detach(); desc.Attach(GetDlgItem(IDC_SETTINGS_EMAIL)); desc.LimitText(35); desc.Detach(); return TRUE; } LRESULT GeneralPage::onTextChanged(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/) { TCHAR buf[SETTINGS_BUF_LEN]; GetDlgItemText(wID, buf, SETTINGS_BUF_LEN); tstring old = buf; // Strip '$', '|', '<', '>' and ' ' from text TCHAR *b = buf, *f = buf, c; while( (c = *b++) != 0 ) { if(c != '$' && c != '|' && (wID == IDC_DESCRIPTION || c != ' ') && ( (wID != IDC_NICK && wID != IDC_DESCRIPTION && wID != IDC_SETTINGS_EMAIL) || (c != '<' && c != '>') ) ) *f++ = c; } *f = '\0'; if(old != buf) { // Something changed; update window text without changing cursor pos CEdit tmp; tmp.Attach(hWndCtl); int start, end; tmp.GetSel(start, end); tmp.SetWindowText(buf); if(start > 0) start--; if(end > 0) end--; tmp.SetSel(start, end); tmp.Detach(); } return TRUE; } /** * @file * $Id$ */