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 UpdateListView(HWND hWnd) { PSY_DEV *dev; int i, count, oldCount, type, status = 0, val; LPTSTR name; LVITEM lvi; #define STR_BUF_SIZE 64 TCHAR statusStr[STR_BUF_SIZE]; if (psy_enum_init()) return; oldCount = ListView_GetItemCount(hWnd); count = psy_enum_get_dev_count(); for (i = 0; i < count; i++) { if (psy_enum_get_dev_item(i, &dev)) break; name = (LPTSTR) psy_dev_get_name(dev); type = psy_dev_get_type(dev); if (type == POWER_SUPPLY_TYPE_BATTERY) { if (psy_dev_get_prop(dev, "status", &status)) break; if (psy_dev_get_prop(dev, "capacity", &val)) break; } else if (psy_dev_get_prop(dev, "online", &val)) break; if (i < oldCount) { ListView_SetItemText(hWnd, i, 0, name); } else { lvi.mask = LVIF_TEXT; lvi.iItem = i; lvi.iSubItem = 0; lvi.pszText = name; ListView_InsertItem(hWnd, &lvi); } ListView_SetItemText(hWnd, i, 1, (LPTSTR) get_psy_type_str(type)); if (type == POWER_SUPPLY_TYPE_BATTERY) StringCbPrintf(statusStr, sizeof(statusStr), _T("%s (%d %%)"), get_psy_status_str(status), val); else StringCbPrintf(statusStr, sizeof(statusStr), val ? _T("On Line") : _T("Off Line")); ListView_SetItemText(hWnd, i, 2, statusStr); } for (; i < oldCount; i++) ListView_DeleteItem(hWnd, i); psy_enum_cleanup(); }
void wxCheckListBox::DoDeleteOneItem(unsigned int n) { wxCHECK_RET( IsValid( n ), wxT("invalid index in wxCheckListBox::Delete") ); if ( !ListView_DeleteItem(GetHwnd(), n) ) { wxLogLastError(wxT("ListView_DeleteItem")); } m_itemsClientData.RemoveAt(n); }
void VerticalFileSwitcherListView::remove(int index) { LVITEM item; item.mask = LVIF_PARAM; item.iItem = index; ListView_GetItem(_hSelf, &item); TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam; delete tlfs; ListView_DeleteItem(_hSelf, index); }
void UpdateProcesses() { int i; ULONG l; LV_ITEM item; LPPROCESS_PAGE_LIST_ITEM pData; SendMessage(hProcessPageListCtrl, WM_SETREDRAW, FALSE, 0); /* Remove old processes */ for (i = 0; i < ListView_GetItemCount(hProcessPageListCtrl); i++) { memset(&item, 0, sizeof (LV_ITEM)); item.mask = LVIF_PARAM; item.iItem = i; (void)ListView_GetItem(hProcessPageListCtrl, &item); pData = (LPPROCESS_PAGE_LIST_ITEM)item.lParam; if (!ProcessRunning(pData->ProcessId)) { (void)ListView_DeleteItem(hProcessPageListCtrl, i); HeapFree(GetProcessHeap(), 0, pData); } } /* Check for difference in listview process and performance process counts */ if (ListView_GetItemCount(hProcessPageListCtrl) != PerfDataGetProcessCount()) { /* Add new processes by checking against the current items */ for (l = 0; l < PerfDataGetProcessCount(); l++) { AddProcess(l); } } if (TaskManagerSettings.SortColumn != -1) { (void)ListView_SortItems(hProcessPageListCtrl, ProcessPageCompareFunc, NULL); } SendMessage(hProcessPageListCtrl, WM_SETREDRAW, TRUE, 0); /* Select first item if any */ if ((ListView_GetNextItem(hProcessPageListCtrl, -1, LVNI_FOCUSED | LVNI_SELECTED) == -1) && (ListView_GetItemCount(hProcessPageListCtrl) > 0) && !bProcessPageSelectionMade) { ListView_SetItemState(hProcessPageListCtrl, 0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); bProcessPageSelectionMade = TRUE; } /* else { bProcessPageSelectionMade = FALSE; } */ }
VOID FilterInsertListItem( IN HWND hWnd, IN HWND hWndTree, IN PFILTER_NODE Node, IN HTREEITEM hTreeItem, IN PWCHAR Buffer, IN BOOLEAN Insert ) { PBTR_FILTER Filter; HWND hWndList; LVITEM lvi = {0}; LVFINDINFO lvfi = {0}; int index; hWndList = GetDlgItem(hWnd, IDC_LIST_FILTER); if (Insert) { ASSERT(Node != NULL); ASSERT(Buffer != NULL); Filter = Node->Filter; index = ListView_GetItemCount(hWndList); lvi.mask = LVIF_PARAM | LVIF_TEXT; lvi.lParam = (LPARAM)hTreeItem; lvi.iItem = index; lvi.iSubItem = 0; lvi.pszText = Filter->FilterName; ListView_InsertItem(hWndList, &lvi); lvi.mask = LVIF_TEXT; lvi.iSubItem = 1; lvi.pszText = Buffer; ListView_SetItem(hWndList, &lvi); return; } // // Delete list item, search by hTreeItem, // note that start position is -1, not 0 // lvfi.flags = LVFI_PARAM; lvfi.lParam = (LPARAM)hTreeItem; index = ListView_FindItem(hWndList, -1, &lvfi); if (index != -1) { ListView_DeleteItem(hWndList, index); } }
void AddLinetoFileView( HWND hDlg , char *text, int deletefirst ) { if ( strlen( text ) > 0 ){ //ListDelString( IDC_VIEWLINES, 0 ); //ListAddString( IDC_VIEWLINES, text ); HWND hlst = GetDlgItem(hDlg, IDC_FILEVIEW); if ( deletefirst ) ListView_DeleteItem( hlst, 1 ); AddToListView( hlst, ListView_GetItemCount(hlst), text ); } }
void KUiWndFrameTabControl::OnDel() { KG_PROCESS_ERROR(m_hListWnd); KG_PROCESS_ERROR(m_nCurrentItem >= 0 && m_nCurrentItem < ListView_GetItemCount(m_hListWnd)); ListView_DeleteItem(m_hListWnd, m_nCurrentItem); m_nCurrentItem = m_nCurrentItem >= ListView_GetItemCount(m_hListWnd) ? m_nCurrentItem - 1 : m_nCurrentItem; ListView_SetItemState(m_hListWnd,m_nCurrentItem,UINT(LVIS_SELECTED | LVIS_FOCUSED ),LVIS_SELECTED | LVIS_FOCUSED); SaveData(); Exit0: return; }
BOOLEAN FilterListOnDelete( IN HWND hWnd, IN UINT uMsg, IN WPARAM wp, IN LPARAM lp ) { int Index; int Count; HTREEITEM hTreeItem; HWND hWndTree; HWND hWndParent; Index = ListViewGetFirstSelected(hWnd); if (Index != -1) { ListViewGetParam(hWnd, Index, (LPARAM *)&hTreeItem); if (hTreeItem != NULL) { ListView_DeleteItem(hWnd, Index); hWndParent = GetParent(hWnd); hWndTree = GetDlgItem(hWndParent, IDC_TREE_FILTER); TreeView_EnsureVisible(hWndTree, hTreeItem); if (BspIsVistaAbove()) { TreeView_SetCheckState(hWndTree, hTreeItem, FALSE); } else { PostMessage(hWndParent, WM_TVN_UNCHECKITEM, (WPARAM)hTreeItem, 0); } Count = ListView_GetItemCount(hWnd); // // If the last item is deleted, start from 0 // if (Count > Index) { ListViewSelectSingle(hWnd, Index); } else { ListViewSelectSingle(hWnd, 0); } return TRUE; } } return FALSE; }
void SongListRemove(int n, PLAYERENTRY* player) { if (n > -1) { PLAYERINFO* current = first; PLAYERINFO* prev = NULL; while (current != NULL) { if (current->n == n) break; else { prev = current; current = current->next; } } if (current != NULL) { PLAYERINFO* next = current->next; while (next != NULL) { next->n--; next = next->next; } if (player->next != NULL && player->next == current) player->next = NULL; if (first == current) first = current->next; if (prev != NULL) { prev->next = current->next; if (last == current) last = prev; } else { if (last == current) last = NULL; } if (current->playing || current->pause) current->n = -1; else PlayInfoRelease(current, TRUE); ListView_DeleteItem(songlist.hWnd, n); } } }
void CShellBrowser::RemoveItem(int iItemInternal) { ULARGE_INTEGER ulFileSize; LVFINDINFO lvfi; BOOL bFolder; int iItem; int nItems; if(iItemInternal == -1) return; CoTaskMemFree(m_pExtraItemInfo[iItemInternal].pridl); /* Is this item a folder? */ bFolder = (m_pwfdFiles[iItemInternal].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY; /* Take the file size of the removed file away from the total directory size. */ ulFileSize.LowPart = m_pwfdFiles[iItemInternal].nFileSizeLow; ulFileSize.HighPart = m_pwfdFiles[iItemInternal].nFileSizeHigh; m_ulTotalDirSize.QuadPart -= ulFileSize.QuadPart; /* Locate the item within the listview. Could use filename, providing removed items are always deleted before new items are inserted. */ lvfi.flags = LVFI_PARAM; lvfi.lParam = iItemInternal; iItem = ListView_FindItem(m_hListView,-1,&lvfi); if(iItem != -1) { /* Remove the item from the listview. */ ListView_DeleteItem(m_hListView,iItem); } /* Invalidate the items internal data. This will mark it as free, so that it can be used by another item. */ m_pItemMap[iItemInternal] = 0; nItems = ListView_GetItemCount(m_hListView); m_nTotalItems--; if(nItems == 0 && !m_bApplyFilter) { SendMessage(m_hOwner,WM_USER_FOLDEREMPTY,m_ID,TRUE); } }
BOOL OnDelete(HWND hWnd) { HWND hWndLV = GetDlgItem(hWnd, IDC_LIST); int nItem = ListView_GetNextItem(hWndLV, -1, LVNI_ALL | LVNI_SELECTED); if (nItem != -1) { if (MessageBox(hWnd, "アイテムを削除しますか。", "確認", MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) == IDYES) { ListView_DeleteItem(hWndLV, nItem); } else { SetFocus(hWndLV); } } return TRUE; }
// Remove a game from favorites void RemoveFromFavorites() { int iSel = SendMessage(hFavListView, LVM_GETNEXTITEM, ~0U, LVNI_FOCUSED); ListView_DeleteItem(hFavListView, iSel); SaveFavListAlt(); // Save the Favorite Games List RefreshFavGameList(); // Refresh Favorite Games List if(ListView_GetItemCount(hFavListView) == 0) { return; } else { SetFocus(hFavListView); ListView_SetItemState(hFavListView, 0, LVIS_SELECTED | LVIS_FOCUSED, 0x000F); } }
void ApplicationListDlg::OnRemoveApplBtn() { //Stop editing item if (IsEditing()) EndEdit(); //Get selected item index int idx = ListView_GetNextItem(m_hAppListWnd, (WPARAM)-1, LVNI_SELECTED); //Remove it from the list if (idx != -1) ListView_DeleteItem(m_hAppListWnd, idx); }
/** * name: ProfileList_DeleteItem * desc: delete an item from the listview * param: hList - handle to listview control * iItem - item index * * return: nothing **/ static VOID ProfileList_DeleteItem(HWND hList, INT iItem) { LPLCITEM pItem = ProfileList_GetItemData(hList, iItem); if (PtrIsValid(pItem)) { if (pItem->pszText[0]) mir_free(pItem->pszText[0]); if (pItem->pszText[1]) mir_free(pItem->pszText[1]); mir_free(pItem); } ListView_DeleteItem(hList, iItem); }
//================================================================================================ //-----------------------------+++--> Remove Timer X From Timer Watch List (Set Homeless to FALSE): void RemoveFromWatch(HWND hWnd, HWND hList, char* szTimer, int iLx) { const char szMessage[] = TEXT("Yes will cancel the timer & remove it from the Watch List\n" "No will remove timer from Watch List only (timer continues)\n" "Cancel will assume you hit delete accidentally (and do nothing)"); char szCaption[GEN_BUFF]; int idx; int id=-1; for(idx=0; idx<m_timers; ++idx) { if(!strcmp(szTimer, m_timer[idx].name)) { id=m_timer[idx].id; break; } } if(id==-1) { //----+++--> IF the Timer Has Expired... ListView_DeleteItem(hList,iLx); // Just Delete it. return; } wsprintf(szCaption, "Cancel Timer (%s) Also?", szTimer); switch(MessageBox(hWnd, szMessage, szCaption, MB_YESNOCANCEL|MB_ICONQUESTION)) { case IDYES: ListView_DeleteItem(hList, iLx); StopTimer(id); // Does Not Reset Active Flag! break; case IDNO: for(idx=0; idx<m_timers; ++idx) { if(!strcmp(szTimer, m_timer[idx].name)) { m_timer[idx].bHomeless = 0; ListView_DeleteItem(hList,iLx); break; } } break; } }
/* Delete the selected frame */ BOOL List_DeleteSelected(HWND hwndApp, HWND hwndList) { int items; /* First get the selected item */ int index = ListView_GetNextItem(hwndList, -1, LVNI_SELECTED); if (index != -1) ListView_DeleteItem(hwndList, index); items = ListView_GetItemCount(hwndList); if (index != -1) return TRUE; else return FALSE; }
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 UpdateFileInfoStatus(FILEINFO *pFileinfo, const HWND hwndListView) { pFileinfo->status = InfoToIntValue(pFileinfo); SetFileInfoStrings(pFileinfo, pFileinfo->parentList); if(g_program_options.bHideVerified && pFileinfo->status == STATUS_OK) { LVFINDINFO findInfo; ZeroMemory(&findInfo, sizeof(LVFINDINFO)); findInfo.flags = LVFI_PARAM; findInfo.lParam = (LPARAM)pFileinfo; int pos = ListView_FindItem(hwndListView, -1, &findInfo); if(pos >= 0) ListView_DeleteItem(hwndListView, pos); } }
int QueueWindow::RemoveQueueItem(QueueOperation * op) { if (!ValidType(op->GetType())) return -1; int index = GetItemIndex(op); if (index == -1) return -1; BOOL res = ListView_DeleteItem(m_hwnd,index); if (res == FALSE) return -1; return -1; }
void InterfaceRemoveList(int session_id) { LV_FINDINFO lvf; int index; lvf.flags = LVFI_PARAM; lvf.lParam = session_id; index = ListView_FindItem(hwndLV,-1,&lvf); if (index >= 0) { ListView_DeleteItem(hwndLV,index); } }
int DBSettingChanged(WPARAM wParam,LPARAM lParam) { DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; HANDLE hContact = (HANDLE)wParam; char *setting; SettingListInfo* info; if (hwnd2mainWindow) { HWND hwnd2Settings = GetDlgItem(hwnd2mainWindow, IDC_SETTINGS); if (info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA)) { if ((hContact == info->hContact) && !mir_strcmp(info->module, cws->szModule)) { setting = mir_strdup(cws->szSetting); if (cws->value.type == DBVT_DELETED) { LVFINDINFO lvfi; int index; lvfi.flags = LVFI_STRING; lvfi.psz = setting; lvfi.vkDirection = VK_DOWN; index = ListView_FindItem(hwnd2Settings, -1, &lvfi); if (index > -1) ListView_DeleteItem(hwnd2Settings, index); mir_free(setting); return 0; } settingChanged(hwnd2Settings, hContact, info->module, setting); mir_free(setting); } } } // watch list if (!hwnd2watchedVarsWindow && !usePopups) return 0; for (int i = 0; i < WatchListArray.count; i++) { if (WatchListArray.item[i].module && (hContact == WatchListArray.item[i].hContact)) { if (!mir_strcmp(cws->szModule, WatchListArray.item[i].module)) { if (!WatchListArray.item[i].setting || !mir_strcmp(cws->szSetting, WatchListArray.item[i].setting)) { if (usePopups) popupWatchedVar(hContact, cws->szModule, cws->szSetting); if (hwnd2watchedVarsWindow) PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS)); break; } } } } return 0; }
//----------------------------------------------------------------------------- // Function: RemovePersonFromListView // // Purpose: Removes the person from the ListView // // Returns: VOID // VOID RemovePersonFromListView(HWND hDlg, LPARAM lParam) { HWND hList = NULL; LVFINDINFO lvItemToFind = {0}; LVITEM lvItem = {0}; int index = -1; PEER_PEOPLE_NEAR_ME * pPerson = (PEER_PEOPLE_NEAR_ME*) lParam; PEER_PEOPLE_NEAR_ME * pTempPerson = NULL; // Setup the search item // lvItemToFind.flags = LVFI_STRING; lvItemToFind.psz = pPerson->pwzNickName; // Setup the LVITEM info wanted // lvItem.mask = LVIF_PARAM; hList = GetDlgItem(hDlg, IDC_PEOPLELIST); // Get the list and find the item // index = ListView_FindItem(hList, index, &lvItemToFind); while (-1 != index) { lvItem.iItem = index; if (ListView_GetItem(hList, &lvItem)) { pTempPerson = (PEER_PEOPLE_NEAR_ME *) lvItem.lParam; if (0 == memcmp(&(pPerson->id), &(pTempPerson->id), sizeof(GUID))) { // Free the person we associated with the list view and delete it from the list view // PeoplePickerModelFreePerson((PEER_PEOPLE_NEAR_ME *)lvItem.lParam); ListView_DeleteItem(hList, index); PeoplePickerModelFreePerson(pPerson); return; } else { index = ListView_FindItem(hList, index, &lvItemToFind); } } } PeoplePickerModelFreePerson(pPerson); }
static VOID OnDeleteVariable(HWND hwndDlg, INT iDlgItem) { HWND hwndListView; PVARIABLE_DATA VarData; LV_ITEM lvi; INT iItem; hwndListView = GetDlgItem(hwndDlg, iDlgItem); iItem = GetSelectedListViewItem(hwndListView); if (iItem != -1) { memset(&lvi, 0x00, sizeof(lvi)); lvi.mask = LVIF_PARAM; lvi.iItem = iItem; if (ListView_GetItem(hwndListView, &lvi)) { VarData = (PVARIABLE_DATA)lvi.lParam; if (VarData != NULL) { if (VarData->lpName != NULL) GlobalFree(VarData->lpName); if (VarData->lpRawValue != NULL) GlobalFree(VarData->lpRawValue); if (VarData->lpCookedValue != NULL) GlobalFree(VarData->lpCookedValue); GlobalFree(VarData); lvi.lParam = 0; } } (void)ListView_DeleteItem(hwndListView, iItem); /* Select the previous item */ if (iItem > 0) iItem--; ListView_SetItemState(hwndListView, iItem, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); } }
void MappingDlg::deleteMappingData() { if (MessageBox(m_hDlg,I18N.MBOX_Delete, I18N.APP_TITLE , MB_YESNO) == IDYES) { int idx; while ((idx = ListView_GetNextItem(m_hList, -1, LVNI_SELECTED)) != -1) { LV_ITEM item = { 0 }; item.mask = LVIF_PARAM; item.iItem = idx; item.iSubItem = 0; ListView_GetItem(m_hList, &item); delete (Mapping*)item.lParam; ListView_DeleteItem(m_hList, idx); m_change = true; } } }
void SelfHealSetup_OnDel( HWND hDlg ) { HWND hwndLV = GetDlgItem( hDlg, IDC_LISTITEMS ); int cur_sel = ListView_GetNextItem( hwndLV, -1, LVNI_SELECTED ); if( cur_sel == -1 ) return; LVITEM lvi; lvi.iItem = cur_sel; lvi.iSubItem = 0; lvi.mask = LVIF_PARAM; lvi.lParam = 0; ListView_GetItem( hwndLV, &lvi ); ListView_DeleteItem( hwndLV, cur_sel ); if( rssh_cur_sel == 0 ) rssh_hit->delItemFromTable( HealItemsTable::HIT_HP, lvi.lParam ); if( rssh_cur_sel == 1 ) rssh_hit->delItemFromTable( HealItemsTable::HIT_MP, lvi.lParam ); if( rssh_cur_sel == 2 ) rssh_hit->delItemFromTable( HealItemsTable::HIT_CP, lvi.lParam ); SelfHealSetup_fillList( hDlg ); }
/** * 使用系统API下载 */ DWORD WINAPI downThread(PVOID pMyPara){ while(ListView_DeleteItem(listHwnd,0));//清空列表 urlLength = 0; SetDlgItemText(mainHwnd,IDC_info,"获取列表中,请稍候..."); int nResult = URLDownloadToFile(NULL,downloadUrl,downlaodPath,NULL,NULL); if (nResult == S_OK) // 表示成功 { SetDlgItemText(mainHwnd,IDC_info,"列表获取成功,分析数据中..."); fenxi(); return TRUE; } else // 表示失败 { SetDlgItemText(mainHwnd,IDC_info,"获取列表失败,请稍后重试..."); } return FALSE; }
static VOID RemoveGroupFromUser(HWND hwndDlg, PMEMBERSHIP_USER_DATA pUserData) { TCHAR szGroupName[UNLEN]; TCHAR szText[256]; LOCALGROUP_MEMBERS_INFO_3 memberInfo; HWND hwndLV; INT nItem; NET_API_STATUS status; hwndLV = GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_LIST); nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED); if (nItem == -1) return; /* Get the new user name */ ListView_GetItemText(hwndLV, nItem, 0, szGroupName, UNLEN); /* Display a warning message because the remove operation cannot be reverted */ wsprintf(szText, TEXT("Do you really want to remove the user \"%s\" from the group \"%s\"?"), pUserData->szUserName, szGroupName); if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING | MB_YESNO) == IDNO) return; memberInfo.lgrmi3_domainandname = pUserData->szUserName; status = NetLocalGroupDelMembers(NULL, szGroupName, 3, (LPBYTE)&memberInfo, 1); if (status != NERR_Success) { TCHAR szText[256]; wsprintf(szText, TEXT("Error: %u"), status); MessageBox(NULL, szText, TEXT("NetLocalGroupDelMembers"), MB_ICONERROR | MB_OK); return; } (void)ListView_DeleteItem(hwndLV, nItem); if (ListView_GetItemCount(hwndLV) == 0) EnableWindow(GetDlgItem(hwndDlg, IDC_USER_MEMBERSHIP_REMOVE), FALSE); }
void MappingDlg::EndDrag(int x, int y) { setInsertMark(-1); m_dragflag = false; ReleaseCapture(); LV_HITTESTINFO ht; ht.pt.x = x; ht.pt.y = y; ListView_HitTest(m_hList, &ht); if ((ht.flags & LVHT_ONITEM) != 0) { LV_ITEM item = { 0 }; item.mask = TVIF_HANDLE; item.iItem = ht.iItem; item.iSubItem = 0; ListView_GetItem(m_hList, &item); item.iItem = ht.iItem; item.iSubItem = 0; item.mask = LVIF_STATE; item.stateMask = LVIS_SELECTED; ListView_GetItem(m_hList, &item); if (item.state & LVIS_SELECTED) return; int idx; while ((idx = ListView_GetNextItem(m_hList, -1, LVNI_SELECTED)) != -1) { LV_ITEM item = { 0 }; item.mask = LVIF_PARAM; item.iItem = idx; item.iSubItem = 0; ListView_GetItem(m_hList, &item); int ret = insertMappingData(ht.iItem, (Mapping*)item.lParam); if (ht.iItem < idx) ht.iItem++; if (ret <= idx) idx++; ListView_DeleteItem(m_hList, idx); m_change = true; } } }
static BOOL UserDelete(HWND hwndDlg) { TCHAR szUserName[UNLEN]; TCHAR szText[256]; INT nItem; HWND hwndLV; NET_API_STATUS status; hwndLV = GetDlgItem(hwndDlg, IDC_USERS_LIST); nItem = ListView_GetNextItem(hwndLV, -1, LVNI_SELECTED); if (nItem == -1) return FALSE; /* Get the new user name */ ListView_GetItemText(hwndLV, nItem, 0, szUserName, UNLEN); /* Display a warning message because the delete operation cannot be reverted */ wsprintf(szText, TEXT("Do you really want to delete the user \"%s\"?"), szUserName); if (MessageBox(NULL, szText, TEXT("User Accounts"), MB_ICONWARNING | MB_YESNO) == IDNO) return FALSE; /* Delete the user */ #if 0 status = NetUserDel(NULL, szUserName); #else status = NERR_Success; #endif if (status != NERR_Success) { TCHAR szText[256]; wsprintf(szText, TEXT("Error: %u"), status); MessageBox(NULL, szText, TEXT("NetUserDel"), MB_ICONERROR | MB_OK); return FALSE; } /* Delete the user from the list */ (void)ListView_DeleteItem(hwndLV, nItem); return TRUE; }