void CPlayListDlg::OnDown(BOOL fVisible) { HWND hwndLV = GetDlgItem(m_hWnd, IDC_PLAY_LIST); SetFocus(hwndLV); int nCount = ListView_GetItemCount(hwndLV); if (ListView_GetItemState(hwndLV, nCount - 1, LVIS_SELECTED)) return; for (int i = nCount - 2; i >= 0; i--) { if (ListView_GetItemState(hwndLV, i, LVIS_SELECTED)) { // ListViewの更新 TCHAR szTitle[MAX_PATH] = {0}; LVITEM li; memset(&li, 0, sizeof(LVITEM)); li.mask = LVIF_TEXT | LVIF_IMAGE; li.iItem = i; li.pszText = szTitle; li.cchTextMax = MAX_PATH; ListView_GetItem(hwndLV, &li); ListView_DeleteItem(hwndLV, i); li.iItem = i + 1; ListView_InsertItem(hwndLV, &li); // プレイリストの更新 m_pParent->DownFile(i); ListView_SetItemState(hwndLV, i + 1, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); if (fVisible) ListView_EnsureVisible(hwndLV, i + 1, FALSE); } } }
BOOL ZipDlg::ListDel() { int intCount = ListView_GetItemCount( hwndList) ; BOOL blnFocus = FALSE ; int i; for( i = 0; i < intCount; i++) { // 選択されていた場合 if( ListView_GetItemState( hwndList, intCount - i - 1, LVIS_SELECTED)) { // 後ろの要素から削除 ListView_DeleteItem( hwndList, intCount - i - 1) ; vector<Mp3File*>::iterator p = vecFileList.begin() + (intCount - i - 1) ; delete vecFileList[ intCount - i - 1] ; vecFileList.erase( p) ; continue ; } } // フォーカスのあるアイテムを選択 for( i = 0; i < ListView_GetItemCount( hwndList); i++) { if( ListView_GetItemState( hwndList, i, LVIS_FOCUSED)) { ListView_SetItemState( hwndList, i, LVIS_SELECTED, LVIS_SELECTED) ; } } EnableWindow( hwndOk, ( ListView_GetItemCount( hwndList) != 0 ? TRUE : FALSE)) ; return TRUE ; }
void CPpcMainWnd::OnFileDown() { if (!ListView_GetSelectedCount(m_hwndLV)) return; int nCount = ListView_GetItemCount(m_hwndLV); if (ListView_GetItemState(m_hwndLV, nCount - 1, LVIS_SELECTED)) return; for (int i = nCount - 2; i >= 0; i--) { if (ListView_GetItemState(m_hwndLV, i, LVIS_SELECTED)) DownFile(i); } }
void CPpcMainWnd::OnFileUp() { if (!ListView_GetSelectedCount(m_hwndLV)) return; int nCount = ListView_GetItemCount(m_hwndLV); if (ListView_GetItemState(m_hwndLV, 0, LVIS_SELECTED)) return; for (int i = 1; i < nCount; i++) { if (ListView_GetItemState(m_hwndLV, i, LVIS_SELECTED)) UpFile(i); } }
void ExchangeItem(HWND hwndLV, int nItem1, int nItem2) { UINT uItem1, uItem2; TCHAR szTitle1[MAX_PATH]; TCHAR szTitle2[MAX_PATH]; ListView_GetItemText(hwndLV, nItem1, 0, szTitle1, MAX_PATH); ListView_GetItemText(hwndLV, nItem2, 0, szTitle2, MAX_PATH); uItem1 = ListView_GetItemState(hwndLV, nItem1, LVIS_FOCUSED | LVIS_SELECTED); uItem2 = ListView_GetItemState(hwndLV, nItem2, LVIS_FOCUSED | LVIS_SELECTED); ListView_SetItemText(hwndLV, nItem1, 0, szTitle2); ListView_SetItemText(hwndLV, nItem2, 0, szTitle1); ListView_SetItemState(hwndLV, nItem1, uItem2, LVIS_FOCUSED | LVIS_SELECTED); ListView_SetItemState(hwndLV, nItem2, uItem1, LVIS_FOCUSED | LVIS_SELECTED); }
void saveSelection(PCSpotify spotify, HWND hwndListView, DWORD setting) { const int itemCount{ ListView_GetItemCount(hwndListView) }; for (int i = 0; i < itemCount; i++) { if (ListView_GetItemState(hwndListView, i, LVIS_SELECTED) == LVIS_SELECTED) { TCHAR buf[MAX_PATH]{}; LV_ITEM item{}; item.iItem = i; item.iSubItem = 1; item.mask = LVIF_TEXT; item.pszText = buf; item.cchTextMax = ARRAYSIZE(buf); if (ListView_GetItem(hwndListView, &item)) { std::cstring cls(item.pszText); if (setting == S2P_SETTING_SPOTIFY) spotify->setSpotifyClass(cls); if (setting == S2P_SETTING_PUTTY) spotify->setPuttyClass(cls); } } } }
static PPH_STRING PhpGetStringForSelectedResults( _In_ HWND ListViewHandle, _In_ PPH_LIST Results, _In_ BOOLEAN All ) { PH_STRING_BUILDER stringBuilder; ULONG i; PhInitializeStringBuilder(&stringBuilder, 0x100); for (i = 0; i < Results->Count; i++) { PPH_MEMORY_RESULT result; if (!All) { if (!(ListView_GetItemState(ListViewHandle, i, LVIS_SELECTED) & LVIS_SELECTED)) continue; } result = Results->Items[i]; PhAppendFormatStringBuilder(&stringBuilder, L"0x%Ix (%u): %s\r\n", result->Address, result->Length, result->Display.Buffer ? result->Display.Buffer : L""); } return PhFinalStringBuilderString(&stringBuilder); }
unsigned pListView::selection() { unsigned count = ListView_GetItemCount(hwnd); for(unsigned n = 0; n < count; n++) { if(ListView_GetItemState(hwnd, n, LVIS_SELECTED)) return n; } return listView.state.selection; }
bool pListView::selected() { unsigned count = ListView_GetItemCount(hwnd); for(unsigned n = 0; n < count; n++) { if(ListView_GetItemState(hwnd, n, LVIS_SELECTED)) return true; } return false; }
void CEffectDlg::PresetOnLoad(HWND hwndDlg) { HWND hwndLV = GetDlgItem(hwndDlg, IDC_LIST_PRESET); int nCount = ListView_GetItemCount(hwndLV); if (!nCount) return; TCHAR szPath[MAX_PATH]; TCHAR szName[MAX_PATH]; if (!GetPresetDir(szPath)) return; for (int i = 0; i < nCount; i++) { if (ListView_GetItemState(hwndLV, i, LVIS_SELECTED) == LVIS_SELECTED) { ListView_GetItemText(hwndLV, i, 0, szName, MAX_PATH); _tcscat(szPath, _T("\\")); _tcscat(szPath, szName); _tcscat(szPath, _T(".")); _tcscat(szPath, EFFECT_FILE_EXT); LoadPresetFile(szPath); return; } } }
BOOL wbGetListViewItemChecked(PWBOBJ pwbo, int nItem) { if(!pwbo || !pwbo->hwnd || !IsWindow(pwbo->hwnd)) return FALSE; return (ListView_GetItemState(pwbo->hwnd, nItem, LVIS_STATEIMAGEMASK) & LVIS_CHECKED); }
static int CustomDrawNewFile(HWND hwnd, LPNMLVCUSTOMDRAW draw) { HWND hwndLV; switch(draw->nmcd.dwDrawStage) { case CDDS_PREPAINT : case CDDS_ITEMPREPAINT: return CDRF_NOTIFYSUBITEMDRAW; case CDDS_ITEMPREPAINT | CDDS_SUBITEM: hwndLV = GetDlgItem(hwnd, IDC_LVNEWPROJECT); // we do it this way so the selection won't go away when we focus another control if (ListView_GetItemState(hwndLV, draw->nmcd.dwItemSpec, LVIS_SELECTED) & LVIS_SELECTED) { draw->clrText = RetrieveSysColor(COLOR_HIGHLIGHTTEXT); draw->clrTextBk = RetrieveSysColor(COLOR_HIGHLIGHT); } else { draw->clrText = RetrieveSysColor(COLOR_WINDOWTEXT); draw->clrTextBk = RetrieveSysColor(COLOR_WINDOW); } return CDRF_NEWFONT; default: return CDRF_DODEFAULT; } }
int CALLBACK ListSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_KEYUP: if (wParam == VK_ESCAPE) SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); break; case WM_SYSKEYDOWN: if (wParam == 'X') SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0); break; case WM_LBUTTONDBLCLK: int count = ListView_GetItemCount(hWnd); for (int i = 0; i < count; i++) { if (ListView_GetItemState(hWnd, i, LVIS_SELECTED)) { TCHAR emailID[4096]; //uhh ListView_GetItemText(hWnd, i, 2, emailID, sizeof(emailID)); exchangeServer.OpenMessage(emailID); } } break; } return CallWindowProc(OldListProc, hWnd, msg, wParam, lParam); }
void CPpcMainWnd::SortFile(int nSort) { #define CURRENT_MASK 0x8000 int i, nFocus = -1; FILEINFO* p; TCHAR szTitle[MAX_PATH]; for (i = 0; i < m_pListFile->GetCount(); i++) { p = (FILEINFO*)m_pListFile->GetAt(i); p->dwUser = (i == m_nCurrent) ? CURRENT_MASK : 0; p->dwUser |= ListView_GetItemState(m_hwndLV, i, LVIS_FOCUSED | LVIS_SELECTED); } m_pListFile->Sort(SortCompareProc, nSort); for (i = 0; i < m_pListFile->GetCount(); i++) { p = (FILEINFO*)m_pListFile->GetAt(i); if (p->dwUser & CURRENT_MASK) m_nCurrent = i; GetTitle(i, szTitle); ListView_SetItemText(m_hwndLV, i, 0, szTitle); ListView_SetItemState(m_hwndLV, i, p->dwUser, LVIS_FOCUSED | LVIS_SELECTED); if (p->dwUser &LVIS_FOCUSED) nFocus = i; } if (nFocus != -1) ListView_EnsureVisible(m_hwndLV, nFocus, FALSE); UpdateTrack(); }
void CEffectDlg::PresetOnDelete(HWND hwndDlg) { CTempStr str; HWND hwndLV = GetDlgItem(hwndDlg, IDC_LIST_PRESET); int nCount = ListView_GetItemCount(hwndLV); if (!nCount) return; TCHAR szMsg[MAX_PATH*2]; TCHAR szPath[MAX_PATH]; TCHAR szName[MAX_PATH]; if (!GetPresetDir(szPath)) return; for (int i = 0; i < nCount; i++) { if (ListView_GetItemState(hwndLV, i, LVIS_SELECTED) == LVIS_SELECTED) { ListView_GetItemText(hwndLV, i, 0, szName, MAX_PATH); str.Load(IDS_FMT_DEL_PRESET); wsprintf(szMsg, str, szName); str.Load(IDS_TITLE_DEL_PRESET); if (MessageBox(hwndDlg, szMsg, str, MB_ICONQUESTION | MB_OKCANCEL) == IDCANCEL) return; _tcscat(szPath, _T("\\")); _tcscat(szPath, szName); _tcscat(szPath, _T(".")); _tcscat(szPath, EFFECT_FILE_EXT); if (DeleteFile(szPath)) ListView_DeleteItem(hwndLV, i); return; } } }
int NListView::ListView_InvertSelection(HWND hListView) { int nTotalItems = ListView_GetItemCount(hListView); int nSelected = 0; SendMessage(hListView,WM_SETREDRAW,FALSE,0); for(int i = 0;i < nTotalItems;i++) { if(ListView_GetItemState(hListView,i,LVIS_SELECTED) == LVIS_SELECTED) { ListView_SelectItem(hListView,i,FALSE); } else { ListView_SelectItem(hListView,i,TRUE); nSelected++; } } SendMessage(hListView,WM_SETREDRAW,TRUE,0); return nSelected; }
void CopyPopupDataToClipboard(HWND hList, int selection) { if (!selection) { return; } if (!GetOpenClipboardWindow()) { if (OpenClipboard(hList)) { TCHAR buffer[2048]; buffer[0] = _T('\0'); TCHAR *clipboard; int i; int found = 0; int count = ListView_GetItemCount(hList); int textType; #ifdef _UNICODE textType = CF_UNICODETEXT; #else textType = CF_TEXT; #endif for (i = 0; i < count; i++) { if (ListView_GetItemState(hList, i, LVIS_SELECTED)) { ListView_GetItemText(hList, i, selection - 100, buffer, 2048); found = 1; break; } } if (found) { EmptyClipboard(); int len = (int)_tcslen(buffer); HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, (len + 2) * sizeof(TCHAR)); clipboard = (TCHAR *) GlobalLock(hData); _tcsncpy(clipboard, buffer, len); clipboard[len] = _T('\0'); GlobalUnlock(hData); if (!SetClipboardData(textType, hData)) { PUShowMessage("Could not set clipboard data", SM_WARNING); } } CloseClipboard(); } else{ PUShowMessage("Could not open clipboard", SM_WARNING); } } else{ PUShowMessage("The clipboard is not available", SM_WARNING); } }
BOOL WmTabCommand_DeleteFunction(HWND, UINT, WPARAM, LPARAM) { HWND hWnd = GetPrgRes()->GetTabWindow(TabWindowFunctions::tab_functions); HWND list = GetDlgItem(hWnd, IDC_FUNCTIONS_LIST); int items = ListView_GetSelectedCount(list); if( items == 0 ) // there must be at least one item selected return true; if( items > 1 ) { // we're showing a message to confirm deleting if( MessageBox( hWnd, GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_delete_function_confirm), GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption), MB_ICONWARNING | MB_YESNO) == IDNO ) return true; } int id; const int buffer_size = 300; char * buffer = new char[buffer_size]; bool all_deleted = true; GetPrgRes()->ReadVariablesFunctionsFromFile(); GetPrgRes()->GetThreadController()->StopCalculating(); for( id = ListView_GetItemCount(list)-1 ; id!=-1 ; --id ) { if( ListView_GetItemState(list, id, LVIS_SELECTED) == LVIS_SELECTED ) { ListView_GetItemText(list,id,0,buffer,buffer_size); if( GetPrgRes()->GetFunctions()->Delete(buffer) != ttmath::err_ok ) all_deleted = false; else ListView_DeleteItem(list, id); GetPrgRes()->FunctionsChanged(); } } GetPrgRes()->GetThreadController()->StartCalculating(); GetPrgRes()->SaveToFile(); delete [] buffer; if( !all_deleted ) // there are some items which we've not deleted // probably an internal error MessageBox( hWnd, GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_function_not_all_deleted), GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption), MB_ICONERROR); return true; }
void MainMenu_OnSelectInv(HWND hwnd) { for(int i = 0; i < ListView_GetItemCount(g_hListWnd); ++i) { int oldstate = ListView_GetItemState(g_hListWnd, i, LVIS_SELECTED); int newstate = (oldstate == LVIS_SELECTED ? 0 : LVIS_SELECTED); ListView_SetItemState(g_hListWnd, i, newstate, LVIS_SELECTED); } SetFocus(g_hListWnd); }
void CEffectDlg::PresetOnSave(HWND hwndDlg) { int i; TCHAR szPath[MAX_PATH]; HWND hwndLV = GetDlgItem(hwndDlg, IDC_LIST_PRESET); for (i = 0; i < sizeof(m_fSaveParam) / sizeof(int); i++) m_fSaveParam[i] = TRUE; *m_szNewName = NULL; int nCount = ListView_GetItemCount(hwndLV); for (i = 0; i < nCount; i++) { if (ListView_GetItemState(hwndLV, i, LVIS_SELECTED) == LVIS_SELECTED) { ListView_GetItemText(hwndLV, i, 0, m_szNewName, MAX_PATH); break; } } if (DialogBoxParam(GetInst(), (LPCTSTR)IDD_PRESETNAME_DLG, hwndDlg, PresetNameDlgProc, (LPARAM)this) != IDOK) return; if (!GetPresetDir(szPath)) return; if (_tcslen(szPath) + _tcslen(EFFECT_FILE_EXT) + 3 > MAX_PATH) return; _tcscat(szPath, _T("\\")); _tcscat(szPath, m_szNewName); _tcscat(szPath, _T(".")); _tcscat(szPath, EFFECT_FILE_EXT); SavePresetFile(szPath, m_fSaveParam[SAVE_PARAM_EQ], m_fSaveParam[SAVE_PARAM_SURROUND], m_fSaveParam[SAVE_PARAM_3DCHORUS], m_fSaveParam[SAVE_PARAM_REVERB], m_fSaveParam[SAVE_PARAM_ECHO], m_fSaveParam[SAVE_PARAM_BASSBOOST]); DWORD dwAttr = GetFileAttributes(szPath); if (dwAttr != 0xFFFFFFFF && !(dwAttr & FILE_ATTRIBUTE_DIRECTORY)) { TCHAR szName[MAX_PATH]; int nCount = ListView_GetItemCount(hwndLV); for (int i = 0; i < nCount; i++) { ListView_GetItemText(hwndLV, i, 0, szName, MAX_PATH); if (_tcsicmp(szName, m_szNewName) == 0) { ListView_SetItemState(hwndLV, i, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); return; } } LVITEM li; memset(&li, 0, sizeof(LVITEM)); li.mask = LVIF_TEXT; li.iItem = ListView_GetItemCount(hwndLV); li.pszText = m_szNewName; nCount = ListView_InsertItem(hwndLV, &li); ListView_SetItemState(hwndLV, nCount, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); } }
static PPH_STRING PhpGetStringForSelectedLogEntries( __in BOOLEAN All ) { PH_STRING_BUILDER stringBuilder; ULONG i; if (ListViewCount == 0) return PhReferenceEmptyString(); PhInitializeStringBuilder(&stringBuilder, 0x100); i = ListViewCount - 1; while (TRUE) { PPH_LOG_ENTRY entry; SYSTEMTIME systemTime; PPH_STRING temp; if (!All) { // The list view displays the items in reverse order... if (!(ListView_GetItemState(ListViewHandle, ListViewCount - i - 1, LVIS_SELECTED) & LVIS_SELECTED)) { goto ContinueLoop; } } entry = PhGetItemCircularBuffer_PVOID(&PhLogBuffer, i); if (!entry) goto ContinueLoop; PhLargeIntegerToLocalSystemTime(&systemTime, &entry->Time); temp = PhFormatDateTime(&systemTime); PhAppendStringBuilder(&stringBuilder, temp); PhDereferenceObject(temp); PhAppendStringBuilder2(&stringBuilder, L": "); temp = PhFormatLogEntry(entry); PhAppendStringBuilder(&stringBuilder, temp); PhDereferenceObject(temp); PhAppendStringBuilder2(&stringBuilder, L"\r\n"); ContinueLoop: if (i == 0) break; i--; } return PhFinalStringBuilderString(&stringBuilder); }
void CPlayListDlg::OnOK() { HWND hwndLV = GetDlgItem(m_hWnd, IDC_PLAY_LIST); int nCount = ListView_GetItemCount(hwndLV); for (int i = 0; i < nCount; i++) { if (ListView_GetItemState(hwndLV, i, LVIS_SELECTED)) { m_pParent->Play(i); break; } } }
int ListView_GetSelection(HWND hList) { int nItems, i; nItems = ListView_GetItemCount(hList); for (i = 0; i < nItems; i++) if (ListView_GetItemState(hList, i, LVIS_SELECTED)) return i; return -1; }
void CPpcMainWnd::OnFileDelete() { int i; if (!ListView_GetSelectedCount(m_hwndLV)) return; int nCount = ListView_GetItemCount(m_hwndLV); for (i = nCount - 1; i >= 0; i--) { if (ListView_GetItemState(m_hwndLV, i, LVIS_SELECTED)) DeleteFile(i); } nCount = ListView_GetItemCount(m_hwndLV); for (i = 0; i < nCount; i++) { if (ListView_GetItemState(m_hwndLV, i, LVIS_FOCUSED)) { ListView_SetItemState(m_hwndLV, i, LVIS_SELECTED, LVIS_SELECTED); break; } } }
bool mxListView::isSelected ( int index ) const { if (!d_this) return false; int state = ListView_GetItemState( d_this->d_hwnd, index, LVIS_SELECTED ); if ( state & LVIS_SELECTED ) return true; return false; }
int ShortcutMapper::getselectedrow() { int i,count,sel=-1; count=ListView_GetItemCount(hlistview); for(i=0;i<count;i++){ if(ListView_GetItemState(hlistview,i,LVIS_SELECTED)==LVIS_SELECTED){ sel=i; break; } } return sel; }
int wxCheckListBox::GetSelection() const { int i; for (i = 0; (unsigned int)i < GetCount(); i++) { int selState = ListView_GetItemState(GetHwnd(), i, LVIS_SELECTED); if (selState == LVIS_SELECTED) return i; } return wxNOT_FOUND; }
int wxCheckListBox::GetSelections(wxArrayInt& aSelections) const { int i; for (i = 0; (unsigned int)i < GetCount(); i++) { int selState = ListView_GetItemState(GetHwnd(), i, LVIS_SELECTED); if (selState == LVIS_SELECTED) aSelections.Add(i); } return aSelections.GetCount(); }
void CPlayListDlg::OnDelete() { HWND hwndLV = GetDlgItem(m_hWnd, IDC_PLAY_LIST); SetFocus(hwndLV); int i; int nCount = ListView_GetItemCount(hwndLV); for (i = nCount - 1; i >= 0; i--) { if (ListView_GetItemState(hwndLV, i, LVIS_SELECTED)) { ListView_DeleteItem(hwndLV, i); m_pParent->DeleteFile(i); } } nCount = ListView_GetItemCount(hwndLV); for (i = 0; i < nCount; i++) { if (ListView_GetItemState(hwndLV, i, LVIS_FOCUSED)) { ListView_SetItemState(hwndLV, i, LVIS_SELECTED, LVIS_SELECTED); break; } } }
int ListView_GetSelItems(HWND hwnd , int count , int * buff) { int i = 0; int sc = ListView_GetSelectedCount(hwnd); int c = ListView_GetItemCount(hwnd); for (int j = 0; j < c; j++) { if (ListView_GetItemState(hwnd , j , LVIS_SELECTED)) { buff[i]=j; i++; if (i>=count || i>=sc) return i; } } return i; }