LRESULT FavHubProperties::OnTextChanged(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/) { TCHAR buf[256]; GetDlgItemText(wID, buf, 256); tstring old = buf; // Strip '$', '|' and ' ' from text TCHAR *b = buf, *f = buf, c; while( (c = *b++) != 0 ) { if(c != '$' && c != '|' && (wID == IDC_HUBUSERDESCR || c != ' ') && ( (wID != IDC_HUBNICK) || (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; }
LRESULT GeneralPage::onTextChanged(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/) { tstring buf; GET_TEXT(wID, buf); tstring old = buf; // TODO: move to Text and cleanup. if (!buf.empty()) { // Strip '$', '|', '<', '>' and ' ' from text TCHAR *b = &buf[0], *f = &buf[0], 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.data()); if (start > 0) start--; if (end > 0) end--; tmp.SetSel(start, end); tmp.Detach(); } return TRUE; }
bool AsGroupsDlg::getItem(tstring& name, bool checkSel) { { CEdit wnd; wnd.Attach(GetDlgItem(IDC_NAME)); name = WinUtil::getEditText(wnd); wnd.Detach(); if (name.empty()) { MessageBox(_T("You must enter a group name!"), CTSTRING(MANAGE_GROUPS), MB_ICONERROR); return false; } else { int32_t pos = findGroup(name.c_str()); if (pos != -1 && (checkSel == false || pos != ctrlGroups.GetSelectedIndex())) { MessageBox(_T("Item already exists!"), CTSTRING(MANAGE_GROUPS), MB_ICONERROR); return false; } } } return true; }
void AsGroupsDlg::updateSelectedGroup(bool forceClean /*= false*/) { tstring name; bool enableButtons = false; if (ctrlGroups.GetSelectedIndex() != -1) { if (forceClean == false) { name = getText(0); } enableButtons = true; } { CWindow wnd; wnd.Attach(GetDlgItem(IDC_REMOVE)); wnd.EnableWindow(enableButtons); wnd.Detach(); wnd.Attach(GetDlgItem(IDC_UPDATE)); wnd.EnableWindow(enableButtons); wnd.Detach(); wnd.Attach(GetDlgItem(IDC_MOVE_DOWN)); wnd.EnableWindow(enableButtons); wnd.Detach(); wnd.Attach(GetDlgItem(IDC_MOVE_UP)); wnd.EnableWindow(enableButtons); wnd.Detach(); } { CEdit wnd; wnd.Attach(GetDlgItem(IDC_NAME)); wnd.SetWindowText(name.c_str()); wnd.Detach(); } }
void CColumnTreeCtrl::OnLButtonDblClk(UINT nFlags, CPoint point) { if (CheckHit(point)) { CTreeCtrl::OnLButtonDblClk(nFlags, point); UINT fFlags; HTREEITEM hItem = HitTest(point, &fFlags); CEdit *edit = EditLabel(hItem); //SetFocus(); class CMyEdit : public CEdit { public: virtual LRESULT DefWindowProc ( UINT message, WPARAM wParam, LPARAM lParam ) { switch(message) { case WM_GETDLGCODE: return DLGC_WANTALLKEYS; // has to do this, otherwise, ESC and RETURN don't work (don't know why ...) break; } return CEdit::DefWindowProc(message, wParam, lParam); } }; CString strSub; AfxExtractSubString(strSub, GetItemText(hItem), 0, '\t'); edit->SetWindowText(strSub); edit->SetSel(0, -1); CMyEdit *me = new CMyEdit; me->SubclassWindow(edit->Detach()); } }
LRESULT FavHubProperties::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) { // Translate dialog SetWindowText(CTSTRING(FAVORITE_HUB_PROPERTIES)); SetDlgItemText(IDCANCEL, CTSTRING(CANCEL)); SetDlgItemText(IDC_FH_HUB, CTSTRING(HUB)); SetDlgItemText(IDC_FH_IDENT, CTSTRING(FAVORITE_HUB_IDENTITY)); SetDlgItemText(IDC_FH_NAME, CTSTRING(HUB_NAME)); SetDlgItemText(IDC_FH_ADDRESS, CTSTRING(HUB_ADDRESS)); SetDlgItemText(IDC_FH_HUB_DESC, CTSTRING(DESCRIPTION)); SetDlgItemText(IDC_FH_NICK, CTSTRING(NICK)); SetDlgItemText(IDC_FH_PASSWORD, CTSTRING(PASSWORD)); SetDlgItemText(IDC_FH_USER_DESC, CTSTRING(DESCRIPTION)); SetDlgItemText(IDC_FH_CONN, CTSTRING(FAVORITE_HUB_CONNECTION)); SetDlgItemText(IDC_STEALTH, CTSTRING(STEALTH_MODE)); SetDlgItemText(IDC_FAV_NO_PM, CTSTRING(FAV_NO_PM)); SetDlgItemText(IDC_SHOW_JOIN, CTSTRING(FAV_SHOW_JOIN)); SetDlgItemText(IDC_HIDE_SHARE, CTSTRING(HIDE_SHARE)); SetDlgItemText(IDC_FAV_SEARCH_INTERVAL, CTSTRING(MINIMUM_SEARCH_INTERVAL)); SetDlgItemText(IDC_FAVGROUP, CTSTRING(GROUP)); SetDlgItemText(IDC_LOGMAINCHAT, CTSTRING(FAV_LOG_CHAT)); SetDlgItemText(IDC_CHAT_NOTIFY, CTSTRING(CHAT_NOTIFY)); SetDlgItemText(IDC_FAILOVER, CTSTRING(ACCEPT_FAILOVERS_FAV)); SetDlgItemText(IDC_AWAY_MSG_LBL, CTSTRING(CUSTOM_AWAY_MESSAGE)); SetDlgItemText(IDC_LOGMAINCHAT, CTSTRING(FAV_LOG_CHAT)); SetDlgItemText(IDC_HUBSETTINGS, CTSTRING(GLOBAL_SETTING_OVERRIDES)); SetDlgItemText(IDC_SEARCH_INTERVAL_DEFAULT, CTSTRING(USE_DEFAULT)); SetDlgItemText(IDC_FAV_SHAREPROFILE_CAPTION, CTSTRING(SHARE_PROFILE)); SetDlgItemText(IDC_EDIT_PROFILES, CTSTRING(EDIT_PROFILES)); SetDlgItemText(IDC_PROFILES_NOTE, CTSTRING(PROFILES_NOTE)); // Fill in values SetDlgItemText(IDC_HUBNAME, Text::toT(entry->getName()).c_str()); SetDlgItemText(IDC_HUBDESCR, Text::toT(entry->getDescription()).c_str()); SetDlgItemText(IDC_HUBADDR, Text::toT(entry->getServerStr()).c_str()); SetDlgItemText(IDC_NICK, Text::toT(entry->get(HubSettings::Nick)).c_str()); SetDlgItemText(IDC_HUBPASS, Text::toT(entry->getPassword()).c_str()); SetDlgItemText(IDC_USERDESC, Text::toT(entry->get(HubSettings::Description)).c_str()); SetDlgItemText(IDC_EMAIL, Text::toT(entry->get(HubSettings::Email)).c_str()); SetDlgItemText(IDC_AWAY_MSG, Text::toT(entry->get(HubSettings::AwayMsg)).c_str()); CheckDlgButton(IDC_STEALTH, entry->getStealth() ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_FAV_NO_PM, entry->getFavNoPM() ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_SHOW_JOIN, toInt(entry->get(HubSettings::ShowJoins))); CheckDlgButton(IDC_SHOW_JOIN_FAV, toInt(entry->get(HubSettings::FavShowJoins))); CheckDlgButton(IDC_LOGMAINCHAT, toInt(entry->get(HubSettings::LogMainChat))); CheckDlgButton(IDC_CHAT_NOTIFY, toInt(entry->get(HubSettings::ChatNotify))); CheckDlgButton(IDC_FAILOVER, toInt(entry->get(HubSettings::AcceptFailovers))); CheckDlgButton(IDC_FAV_NO_PM, entry->getFavNoPM() ? BST_CHECKED : BST_UNCHECKED); auto searchInterval = entry->get(HubSettings::SearchInterval); CheckDlgButton(IDC_SEARCH_INTERVAL_DEFAULT, searchInterval == HubSettings::getMinInt() ? BST_CHECKED : BST_UNCHECKED); SetDlgItemText(IDC_FAV_SEARCH_INTERVAL_BOX, Util::toStringW(searchInterval).c_str()); bool isAdcHub = entry->isAdcHub(); CComboBox combo; combo.Attach(GetDlgItem(IDC_FAVGROUP_BOX)); combo.AddString(_T("---")); combo.SetCurSel(0); const FavHubGroups& favHubGroups = FavoriteManager::getInstance()->getFavHubGroups(); for(const auto& name: favHubGroups | map_keys) { int pos = combo.AddString(Text::toT(name).c_str()); if(name == entry->getGroup()) combo.SetCurSel(pos); } combo.Detach(); // TODO: add more encoding into wxWidgets version, this is enough now // FIXME: following names are Windows only! combo.Attach(GetDlgItem(IDC_ENCODING)); combo.AddString(_T("System default")); combo.AddString(_T("English_United Kingdom.1252")); combo.AddString(_T("Czech_Czech Republic.1250")); combo.AddString(_T("Russian_Russia.1251")); combo.AddString(Text::toT(Text::utf8).c_str()); ctrlProfile.Attach(GetDlgItem(IDC_FAV_SHAREPROFILE)); appendProfiles(); hideShare = entry->getShareProfile() && entry->getShareProfile()->getToken() == SP_HIDDEN; CheckDlgButton(IDC_HIDE_SHARE, hideShare ? BST_CHECKED : BST_UNCHECKED); if(isAdcHub) { combo.SetCurSel(4); // select UTF-8 for ADC hubs combo.EnableWindow(false); if (hideShare) ctrlProfile.EnableWindow(false); } else { ctrlProfile.EnableWindow(false); if(entry->getEncoding().empty()) { combo.SetCurSel(0); } else { combo.SetWindowText(Text::toT(entry->getEncoding()).c_str()); } } combo.Detach(); // connection modes auto appendCombo = [](CComboBox& combo, int curMode) { combo.InsertString(0, CTSTRING(DEFAULT)); combo.InsertString(1, CTSTRING(DISABLED)); combo.InsertString(2, CTSTRING(ACTIVE_MODE)); combo.InsertString(3, CTSTRING(PASSIVE_MODE)); if(curMode == HubSettings::getMinInt()) combo.SetCurSel(0); else if(curMode == SettingsManager::INCOMING_DISABLED) combo.SetCurSel(1); else if(curMode == SettingsManager::INCOMING_ACTIVE) combo.SetCurSel(2); else if(curMode == SettingsManager::INCOMING_PASSIVE) combo.SetCurSel(3); }; modeCombo4.Attach(GetDlgItem(IDC_MODE4)); modeCombo6.Attach(GetDlgItem(IDC_MODE6)); appendCombo(modeCombo4, entry->get(HubSettings::Connection)); appendCombo(modeCombo6, entry->get(HubSettings::Connection6)); //external ips SetDlgItemText(IDC_SERVER4, Text::toT(entry->get(HubSettings::UserIp)).c_str()); SetDlgItemText(IDC_SERVER6, Text::toT(entry->get(HubSettings::UserIp6)).c_str()); fixControls(); CEdit tmp; tmp.Attach(GetDlgItem(IDC_HUBNAME)); tmp.SetFocus(); tmp.SetSel(0,-1); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_NICK)); tmp.LimitText(35); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_USERDESC)); tmp.LimitText(50); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_EMAIL)); tmp.LimitText(50); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_HUBPASS)); tmp.SetPasswordChar('*'); tmp.Detach(); CUpDownCtrl updown; updown.Attach(GetDlgItem(IDC_FAV_SEARCH_INTERVAL_SPIN)); updown.SetRange32(5, 9999); updown.Detach(); CenterWindow(GetParent()); loaded = true; return FALSE; }
LRESULT FavHubProperties::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) { // Translate dialog SetWindowText(CTSTRING(FAVORITE_HUB_PROPERTIES)); SetDlgItemText(IDOK, CTSTRING(OK)); SetDlgItemText(IDCANCEL, CTSTRING(CANCEL)); SetDlgItemText(IDC_FH_HUB, CTSTRING(HUB)); SetDlgItemText(IDC_FH_IDENT, CTSTRING(FAVORITE_HUB_IDENTITY)); SetDlgItemText(IDC_FH_NAME, CTSTRING(HUB_NAME)); SetDlgItemText(IDC_FH_ADDRESS, CTSTRING(HUB_ADDRESS)); SetDlgItemText(IDC_FH_HUB_DESC, CTSTRING(DESCRIPTION)); SetDlgItemText(IDC_FH_NICK, CTSTRING(NICK)); SetDlgItemText(IDC_FH_PASSWORD, CTSTRING(PASSWORD)); SetDlgItemText(IDC_FH_USER_DESC, CTSTRING(DESCRIPTION)); SetDlgItemText(IDC_DEFAULT, CTSTRING(DEFAULT)); SetDlgItemText(IDC_ACTIVE, CTSTRING(SETTINGS_DIRECT)); SetDlgItemText(IDC_PASSIVE, CTSTRING(SETTINGS_FIREWALL_PASSIVE)); SetDlgItemText(IDC_STEALTH, CTSTRING(STEALTH_MODE)); SetDlgItemText(IDC_FAV_SEARCH_INTERVAL, CTSTRING(MINIMUM_SEARCH_INTERVAL)); SetDlgItemText(IDC_FAVGROUP, CTSTRING(GROUP)); // Fill in values SetDlgItemText(IDC_HUBNAME, Text::toT(entry->getName()).c_str()); SetDlgItemText(IDC_HUBDESCR, Text::toT(entry->getDescription()).c_str()); SetDlgItemText(IDC_HUBADDR, Text::toT(entry->getServer()).c_str()); SetDlgItemText(IDC_HUBNICK, Text::toT(entry->getNick(false)).c_str()); SetDlgItemText(IDC_HUBPASS, Text::toT(entry->getPassword()).c_str()); SetDlgItemText(IDC_HUBUSERDESCR, Text::toT(entry->getUserDescription()).c_str()); CheckDlgButton(IDC_STEALTH, entry->getStealth() ? BST_CHECKED : BST_UNCHECKED); SetDlgItemText(IDC_RAW_ONE, Text::toT(entry->getRawOne()).c_str()); SetDlgItemText(IDC_RAW_TWO, Text::toT(entry->getRawTwo()).c_str()); SetDlgItemText(IDC_RAW_THREE, Text::toT(entry->getRawThree()).c_str()); SetDlgItemText(IDC_RAW_FOUR, Text::toT(entry->getRawFour()).c_str()); SetDlgItemText(IDC_RAW_FIVE, Text::toT(entry->getRawFive()).c_str()); SetDlgItemText(IDC_SERVER, Text::toT(entry->getIP()).c_str()); SetDlgItemText(IDC_FAV_SEARCH_INTERVAL_BOX, Util::toStringW(entry->getSearchInterval()).c_str()); CComboBox combo; combo.Attach(GetDlgItem(IDC_FAVGROUP_BOX)); combo.AddString(_T("---")); combo.SetCurSel(0); const FavHubGroups& favHubGroups = FavoriteManager::getInstance()->getFavHubGroups(); for(FavHubGroups::const_iterator i = favHubGroups.begin(); i != favHubGroups.end(); ++i) { const string& name = i->first; int pos = combo.AddString(Text::toT(name).c_str()); if(name == entry->getGroup()) combo.SetCurSel(pos); } combo.Detach(); // TODO: add more encoding into wxWidgets version, this is enough now // FIXME: following names are Windows only! combo.Attach(GetDlgItem(IDC_ENCODING)); combo.AddString(_T("System default")); combo.AddString(_T("English_United Kingdom.1252")); combo.AddString(_T("Czech_Czech Republic.1250")); combo.AddString(_T("Russian_Russia.1251")); combo.AddString(Text::toT(Text::utf8).c_str()); if(strnicmp("adc://", entry->getServer().c_str(), 6) == 0 || strnicmp("adcs://", entry->getServer().c_str(), 7) == 0) { combo.SetCurSel(4); // select UTF-8 for ADC hubs combo.EnableWindow(false); } else { if(entry->getEncoding().empty()) combo.SetCurSel(0); else combo.SetWindowText(Text::toT(entry->getEncoding()).c_str()); } combo.Detach(); if(entry->getMode() == 0) CheckRadioButton(IDC_ACTIVE, IDC_DEFAULT, IDC_DEFAULT); else if(entry->getMode() == 1) CheckRadioButton(IDC_ACTIVE, IDC_DEFAULT, IDC_ACTIVE); else if(entry->getMode() == 2) CheckRadioButton(IDC_ACTIVE, IDC_DEFAULT, IDC_PASSIVE); CEdit tmp; tmp.Attach(GetDlgItem(IDC_HUBNAME)); tmp.SetFocus(); tmp.SetSel(0,-1); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_HUBNICK)); tmp.LimitText(35); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_HUBUSERDESCR)); tmp.LimitText(50); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_HUBPASS)); tmp.SetPasswordChar('*'); tmp.Detach(); CUpDownCtrl updown; updown.Attach(GetDlgItem(IDC_FAV_SEARCH_INTERVAL_SPIN)); updown.SetRange32(10, 9999); updown.Detach(); CenterWindow(GetParent()); return FALSE; }
LRESULT FavHubGeneralPage::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) { // Translate dialog SetWindowText(CTSTRING(FAVORITE_HUB_PROPERTIES)); SetDlgItemText(IDCANCEL, CTSTRING(CANCEL)); SetDlgItemText(IDC_FH_HUB, CTSTRING(HUB)); SetDlgItemText(IDC_FH_IDENT, CTSTRING(FAVORITE_HUB_IDENTITY)); SetDlgItemText(IDC_FH_NAME, CTSTRING(NAME)); SetDlgItemText(IDC_FH_ADDRESS, CTSTRING(HUB_ADDRESS)); SetDlgItemText(IDC_FH_HUB_DESC, CTSTRING(DESCRIPTION)); SetDlgItemText(IDC_FH_NICK, CTSTRING(NICK)); SetDlgItemText(IDC_FH_PASSWORD, CTSTRING(PASSWORD)); SetDlgItemText(IDC_FH_USER_DESC, CTSTRING(DESCRIPTION)); SetDlgItemText(IDC_FAVGROUP, CTSTRING(GROUP)); SetDlgItemText(IDC_ENCODINGTEXT, CTSTRING(NMDC_ENCODING)); SetDlgItemText(IDC_HIDE_SHARE, CTSTRING(HIDE_SHARE)); SetDlgItemText(IDC_FAV_SHAREPROFILE_CAPTION, CTSTRING(SHARE_PROFILE)); SetDlgItemText(IDC_EDIT_PROFILES, CTSTRING(EDIT_PROFILES)); SetDlgItemText(IDC_PROFILES_NOTE, CTSTRING(PROFILES_NOTE)); // Fill in values SetDlgItemText(IDC_HUBNAME, Text::toT(entry->getName()).c_str()); SetDlgItemText(IDC_HUBDESCR, Text::toT(entry->getDescription()).c_str()); SetDlgItemText(IDC_HUBADDR, Text::toT(entry->getServer()).c_str()); SetDlgItemText(IDC_NICK, Text::toT(entry->get(HubSettings::Nick)).c_str()); SetDlgItemText(IDC_HUBPASS, Text::toT(entry->getPassword()).c_str()); SetDlgItemText(IDC_USERDESC, Text::toT(entry->get(HubSettings::Description)).c_str()); SetDlgItemText(IDC_EMAIL, Text::toT(entry->get(HubSettings::Email)).c_str()); bool isAdcHub = entry->isAdcHub(); CComboBox tmpCombo; tmpCombo.Attach(GetDlgItem(IDC_FAVGROUP_BOX)); tmpCombo.AddString(_T("---")); tmpCombo.SetCurSel(0); const FavHubGroups& favHubGroups = FavoriteManager::getInstance()->getFavHubGroups(); for (const auto& n : favHubGroups | map_keys) { int pos = tmpCombo.AddString(Text::toT(n).c_str()); if (n == entry->getGroup()) tmpCombo.SetCurSel(pos); } tmpCombo.Detach(); // TODO: add more encoding into wxWidgets version, this is enough now // FIXME: following names are Windows only! ctrlEncoding.Attach(GetDlgItem(IDC_ENCODING)); ctrlEncoding.AddString(CTSTRING(SYSTEM_DEFAULT)); ctrlEncoding.AddString(_T("English_United Kingdom.1252")); ctrlEncoding.AddString(_T("Czech_Czech Republic.1250")); ctrlEncoding.AddString(_T("Russian_Russia.1251")); ctrlEncoding.AddString(Text::toT(Text::utf8).c_str()); ctrlProfile.Attach(GetDlgItem(IDC_FAV_SHAREPROFILE)); appendProfiles(); hideShare = entry->get(HubSettings::ShareProfile) == SP_HIDDEN; CheckDlgButton(IDC_HIDE_SHARE, hideShare ? BST_CHECKED : BST_UNCHECKED); if (isAdcHub) { ctrlEncoding.SetCurSel(4); // select UTF-8 for ADC hubs ctrlEncoding.EnableWindow(false); if (hideShare) ctrlProfile.EnableWindow(false); } else { ctrlProfile.EnableWindow(false); if (entry->get(HubSettings::NmdcEncoding).empty() || entry->get(HubSettings::NmdcEncoding) == "System default") { ctrlEncoding.SetCurSel(0); } else { ctrlEncoding.SetWindowText(Text::toT(entry->get(HubSettings::NmdcEncoding)).c_str()); } } CEdit tmp; tmp.Attach(GetDlgItem(IDC_HUBNAME)); tmp.SetFocus(); tmp.SetSel(0, -1); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_NICK)); tmp.LimitText(35); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_USERDESC)); tmp.LimitText(50); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_EMAIL)); tmp.LimitText(50); tmp.Detach(); tmp.Attach(GetDlgItem(IDC_HUBPASS)); tmp.SetPasswordChar('*'); tmp.Detach(); loading = false; return FALSE; }