BOOL ZipDlg::ListAdd( Mp3File* pMp3, int intNum) { intNum = ( intNum < 0 ? ListView_GetItemCount( hwndList) : intNum) ; vector< Mp3File*>::iterator p = vecFileList.begin() + intNum ; // アイコン取得 SHFILEINFO shfi ; SHGetFileInfo( pMp3->GetFilePath().c_str(), 0, &shfi, sizeof(SHFILEINFO), SHGFI_SYSICONINDEX | SHGFI_SMALLICON); // 表示文字列取得 string filename = pMp3->GetSaveName(); string fullpath = pMp3->GetFilePath(); // アイテム設定 LVITEM item = { LVIF_TEXT | LVIF_STATE | LVIF_PARAM | LVIF_IMAGE} ; intNum = ( intNum < 0 ? ListView_GetItemCount( hwndList) : intNum) ; item.iItem = intNum ; item.state = LVIS_SELECTED ; item.lParam = (LPARAM)pMp3 ; item.pszText = (LPTSTR)filename.c_str() ; item.iSubItem = 0 ; item.iImage = shfi.iIcon ; ListView_InsertItem( hwndList, &item) ; ListView_SetItemText( hwndList, intNum, 1, (LPTSTR)fullpath.c_str()) ; // リロード ListReload() ; return TRUE ; }
void MainWindow::on_butOD_clicked() { dlsiteimage.clear(); SendMsg("Open Directory..."); currentDirectory = QFileDialog::getExistingDirectory(this, tr("Open Directory"),currentDirectory); SendMsg("Directory Path : "+currentDirectory); this->setWindowTitle(currentDirectory); ListReload(); }
BOOL ZipDlg::ListMove( BOOL blnUp) { int intSize = ListView_GetItemCount( hwndList) ; bool blnMoved = false ; // 動く余地があるかどうか int intIndex ; vector<BOOL> vecSelected ; BOOL blnTop = TRUE ; for( int i = 0; i < intSize; i++) { intIndex = blnUp ? i : intSize - i - 1 ; if( ListView_GetItemState( hwndList, intIndex, LVIS_SELECTED)) { if( !blnMoved) { continue ; } // リストビュー ListView_DeleteItem( hwndList, intIndex) ; if( blnUp) // index減少 { ListAdd( vecFileList[ intIndex], intIndex - 1) ; } else { ListAdd( vecFileList[ intIndex], intIndex + 1) ; } if( blnTop) { ListView_SetItemState( hwndList, intIndex + ( blnUp ? -1 : 1), LVIS_FOCUSED, LVIS_FOCUSED) ; ListView_EnsureVisible( hwndList, intIndex + ( blnUp ? -1 : 1), FALSE) ; blnTop = FALSE ; } // ドキュメント ListReload() ; } else { blnMoved = true ; } } return TRUE ; }
void ZipDlg::ListSetFolder() { // 初期値取得 string str ; int intCount = ListView_GetItemCount( hwndList) ; int i ; for( i = 0; i < intCount; i++) { if( ListView_GetItemState( hwndList, i, LVIS_SELECTED)) { str = GetDirName( vecFileList[ i]->GetSaveName()) ; break ; } } // 編集 DialogBoxParam( hInstance, MAKEINTRESOURCE( IDD_FOLDERNAME), m_hWnd, FileNameDlgProc, (LPARAM)&str) ; if( str.size() > 0 && str[ str.size() - 1] != '\\') { str += "\\" ; } intCount = ListView_GetItemCount( hwndList) ; BOOL blnFocus = FALSE ; for( i = 0; i < intCount; i++) { // 選択されていた場合 if( ListView_GetItemState( hwndList, i, LVIS_SELECTED)) { // 削除 string s = GetFileName( vecFileList[ i]->GetSaveName()) ; vecFileList[ i]->SetSaveName( str + s) ; } } ListReload( TRUE) ; }
BOOL ZipDlg::OnListNotify( HWND hDlg, WPARAM wParam, LPARAM lParam) { NMHDR* nmhdr = (NMHDR*)lParam ; // キーダウン if( nmhdr->code == LVN_KEYDOWN) { // デリート if( ( (LPNMLVKEYDOWN)lParam)->wVKey == VK_DELETE) { ListDel( ) ; EnableWindow( hwndOk, ( ListView_GetItemCount( hwndList) != 0 ? TRUE : FALSE)) ; } // Ctrl + A else if( GetKeyState( VK_CONTROL) < 0 && ( (LPNMLVKEYDOWN)lParam)->wVKey == 'A') { ListView_SetItemState( hwndList, -1, LVIS_SELECTED, LVIS_SELECTED) ; } // Alt + ↑↓ else if( GetKeyState( VK_MENU) < 0) { if( ( (LPNMLVKEYDOWN)lParam)->wVKey == VK_UP) { ListMove( TRUE) ; } else if( ( (LPNMLVKEYDOWN)lParam)->wVKey == VK_DOWN) { ListMove( FALSE) ; } } return TRUE ; } // 選択変更時 else if( nmhdr->code == LVN_ITEMCHANGED) { EnableWindow( hwndOk, ( ListView_GetItemCount( hwndList) != 0 ? TRUE : FALSE)) ; EnableWindow( hwndDel, ( ListView_GetSelectedCount( hwndList) != 0 ? TRUE : FALSE)) ; return TRUE ; } // ヘッダ部分クリック else if( nmhdr->code == LVN_COLUMNCLICK) { ListView_SortItems( hwndList, ListSortProc, ( (NMLISTVIEW*)lParam)->iSubItem) ; ListReload() ; return TRUE ; } // 右クリック else if( nmhdr->code == NM_RCLICK) { POINT pt ; GetCursorPos( &pt) ; HMENU hMenu = LoadMenu( hInstance, MAKEINTRESOURCE(IDR_POPMENU)) ; HMENU hMenuPopup = GetSubMenu( hMenu, 0) ; if( ListView_GetSelectedCount( hwndList) == 0) { EnableMenuItem( hMenuPopup, IDM_DEL, MF_BYCOMMAND | MF_GRAYED) ; EnableMenuItem( hMenuPopup, IDM_SETFOLDER, MF_BYCOMMAND | MF_GRAYED) ; EnableMenuItem( hMenuPopup, IDM_UP, MF_BYCOMMAND | MF_GRAYED) ; EnableMenuItem( hMenuPopup, IDM_DOWN, MF_BYCOMMAND | MF_GRAYED) ; } if( ListView_GetItemCount( hwndList) == 0) { EnableMenuItem( hMenuPopup, IDM_SORTFILE, MF_BYCOMMAND | MF_GRAYED) ; EnableMenuItem( hMenuPopup, IDM_SORTPATH, MF_BYCOMMAND | MF_GRAYED) ; EnableMenuItem( hMenuPopup, IDM_SORTZIP, MF_BYCOMMAND | MF_GRAYED) ; } DWORD dwID = TrackPopupMenu( hMenuPopup, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, hDlg, NULL) ; switch( dwID) { case IDM_ADD: ListAddFileDlg() ; break ; case IDM_DEL: ListDel() ; break ; case IDM_UP: case IDM_DOWN: ListMove( dwID == IDM_UP) ; break ; case IDM_SORTPATH: ListView_SortItems( hwndList, ListSortProc, 1) ; ListReload() ; break ; case IDM_SORTFILE: ListView_SortItems( hwndList, ListSortProc, 2) ; ListReload() ; break ; case IDM_SORTZIP: ListView_SortItems( hwndList, ListSortProc, 0) ; ListReload() ; break ; case IDM_SETFOLDER: ListSetFolder() ; break ; } DestroyMenu( hMenu) ; } return FALSE ; }