int Twindow::selectFromMenu(const strings &items,int id,bool translate,int columnHeight) { Tstrptrs ptritems; for (strings::const_iterator s=items.begin(); s!=items.end(); s++) { ptritems.push_back(s->c_str()); } ptritems.push_back(NULL); return selectFromMenu(&ptritems[0],id,translate,columnHeight); }
INT_PTR TpresetAutoloadDlgBase::TitemsWindow::msgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_COMMAND) { int id = LOWORD(wParam) - 1000; if (id > 0 && id / 10 < (int)items.size()) { Titem &item = items[id / 10]; if ((id % 10) == 1) { item.is = 1 - item.is; item.wasChange = true; } else if ((id % 10) == 2) { if (HIWORD(wParam) == EN_CHANGE && !isSetWindowText) { GetDlgItemText(m_hwnd, LOWORD(wParam), item.val, 256); item.wasChange = true; } } else if ((id % 10) == 3) { Tstrptrs mitems; const char_t *mitem; for (unsigned int li = 0; (mitem = deciD->getPresetAutoloadItemList(id / 10, li)) != NULL; li++) { mitems.push_back(mitem); } mitems.push_back(NULL); int idx = selectFromMenu(&mitems[0], LOWORD(wParam), false, 20); if (idx >= 0) { if (item.val[0] != '\0') { strncat_s(item.val, countof(item.val), _l(";"), _TRUNCATE); } strncat_s(item.val, countof(item.val), mitems[idx], _TRUNCATE); HWND hed = GetDlgItem(m_hwnd, LOWORD(wParam) - 1); SetWindowText(hed, item.val); size_t len = strlen(item.val); SendMessage(hed, EM_SETSEL, len, len); } } else if ((id % 10) == 4) { const char_t *help; if (deciD->getPresetAutoloadItemHelp(id / 10, &help) == S_OK) { msg(_(-IDD_PRESET_AUTOLOAD_ITEMS, help), _(-IDD_PRESET_AUTOLOAD_ITEMS, _l("Preset autoload condition help"))); } } } } else if (uMsg == WM_VSCROLL) { SCROLLINFO si; si.cbSize = sizeof(si); si.fMask = SIF_ALL; GetScrollInfo(m_hwnd, SB_VERT, &si); int oldpos = si.nPos; switch (LOWORD(wParam)) { case SB_LINELEFT: si.nPos--; break; case SB_LINERIGHT: si.nPos++; break; case SB_PAGELEFT: si.nPos -= si.nPage; break; case SB_PAGERIGHT: si.nPos += si.nPage; break; case SB_THUMBTRACK: si.nPos = si.nTrackPos; break; default: break; } si.fMask = SIF_POS; SetScrollInfo(m_hwnd, SB_VERT, &si, TRUE); GetScrollInfo(m_hwnd, SB_VERT, &si); if (si.nPos != oldpos) { ScrollWindow(m_hwnd, 0, oldpos - si.nPos, NULL, NULL); } } return TdlgWindow::msgProc(uMsg, wParam, lParam); }