int ListBox_MoveString(HWND hwndListBox, int iIndex, int iNewIndex, BOOL bRelativeToOld) { int iCount = ListBox_GetCount(hwndListBox); int nExactNewIndex; if (iIndex == 0 && iNewIndex < 0) iNewIndex = 0; nExactNewIndex = bRelativeToOld ? (iIndex + iNewIndex) : iNewIndex; if ((bRelativeToOld && (iIndex + iNewIndex) >= iCount) || (iNewIndex >= iCount)) { return (LB_ERR); } else { LPTSTR pszBuffer = (LPTSTR)Mem_AllocStr(ListBox_GetTextLen(hwndListBox, iIndex) + SZ); LPVOID lpVoid = (LPVOID)ListBox_GetItemData(hwndListBox, iIndex); ListBox_GetText(hwndListBox, iIndex, pszBuffer); ListBox_DeleteString(hwndListBox, iIndex); ListBox_InsertString(hwndListBox, nExactNewIndex, pszBuffer); ListBox_SetItemData(hwndListBox, nExactNewIndex, lpVoid); Mem_Free(pszBuffer); } return (nExactNewIndex); }
/* * ReplaceItem() - */ void TxLbx_ReplaceItem(HWND listBox, int idx, const _TUCHAR *text, DWORD itemData , TXLBX_ATTR attr) { ListBox_DeleteString(listBox, idx); ListBox_InsertString(listBox, idx, text); ListBox_SetItemData(listBox, idx, attr | (itemData & 0x00FFFFFF)); }
///////////////////////////////////////////////////////////////////////// //Function: RemoveItem //Description: remove a item from selected object list ///////////////////////////////////////////////////////////////////////// void RemoveItem(HWND hDlg) { long nObjects ; long Index ; EnableWindow(GetDlgItem(hDlg, removeB), FALSE) ; EnableWindow(GetDlgItem(hDlg, editB), FALSE) ; /*nObjects = SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETSELCOUNT, 0, 0L) ; if (nObjects!=0 &&(0!=SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETCOUNT, 0, 0))) { while(SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_GETSELITEMS, 1, (long) &Index) !=0) { SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_DELETESTRING, (WORD)Index, 0) ; } SendDlgItemMessage (hDlg, IDD_FIELDSLIST, LB_SETCARETINDEX, 0, 0) ; }*/ nObjects = ListBox_GetSelCount (GetDlgItem(hDlg, IDD_FIELDSLIST)) ; if(nObjects!=0&&(0!=ListBox_GetCount(GetDlgItem(hDlg, IDD_FIELDSLIST)))) { while(ListBox_GetSelItems (GetDlgItem(hDlg,IDD_FIELDSLIST),1, &Index)!=0) { ListBox_DeleteString (GetDlgItem(hDlg, IDD_FIELDSLIST), Index) ; } ListBox_SetCaretIndex (GetDlgItem(hDlg, IDD_FIELDSLIST),0) ; } SetFocus(GetDlgItem (hDlg,IDD_FIELDSLIST)) ; }
/* This function removes an item from the outbasket. */ void FASTCALL DeleteFromOutBasket( LPOB lpob ) { /* Now closes down the window if there is one * YH 03/05/96 */ HWND hwndSay; if( hwndSay = Amob_GetEditWindow( lpob ) ) SendDlgCommand( hwndSay, IDCANCEL, BN_CLICKED ); if( NULL != hwndOutBasket && !fIgnoreDeleteEvent ) { HWND hwndList; hwndList = GetDlgItem( hwndOutBasket, IDD_LIST ); if( hwndList ) { int wCount; int nSel; wCount = ListBox_GetCount( hwndList ); for( nSel = 0; nSel < wCount; ++nSel ) if( (LPOB)ListBox_GetItemData( hwndList, nSel ) == lpob ) { if( ListBox_DeleteString( hwndList, nSel ) == nSel ) --nSel; if( ListBox_GetSelCount( hwndList ) == 0 ) ListBox_SetSel( hwndList, TRUE, nSel ); break; } } UpdateOutBasketStatus(); } }
/* * StatsListChangeStat: Redisplay current statistic, whose value has changed. * Requires that s is a list type stat in the current group. */ void StatsListChangeStat(Statistic *s) { int index, top; if (s->num < 0 || s->num > ListBox_GetCount(hList)) { debug(("StatListChangeList got illegal stat #%d\n", (int) s->num)); return; } top = ListBox_GetTopIndex(hList); index = StatListFindItem(s->num); if (index == -1) { debug(("StatListChangeList got illegal stat #%d\n", (int) s->num)); return; } WindowBeginUpdate(hList); ListBox_DeleteString(hList, index); index = ListBox_AddString(hList, LookupNameRsc(s->name_res)); ListBox_SetItemData(hList, index, s); ListBox_SetTopIndex(hList, top); WindowEndUpdate(hList); }
static void DispInfoExt(HWND hDlg,CShellExt *lpcs) { //クリア long items = ListBox_GetCount(GetDlgItem(hDlg,IDC_LIST_VALUE)); if(items != LB_ERR) { for(int i=0; i<items; i++) { COggExt *oggExt = (COggExt *)ListBox_GetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),0); if(oggExt) { delete oggExt; } ListBox_DeleteString(GetDlgItem(hDlg,IDC_LIST_VALUE),0); } } CString strDisp; CStringArray strArray; lpcs->m_Ogg.GetCommentNames(strArray); items = 0; for(int i=0; i<strArray.GetSize(); i++) { CString strName = strArray.GetAt(i); CString strValue; CString _strValue; int j = 0; while(1) { if(!lpcs->m_Ogg.GetComment(strName,j++,strValue)) { break; } //標準名は除外 if((j == 1) && ( !strName.Compare(_T("TITLE")) || !strName.Compare(_T("TRACKNUMBER")) || !strName.Compare(_T("ARTIST")) || !strName.Compare(_T("ALBUM")) || !strName.Compare(_T("ALBUMARTIST")) || !strName.Compare(_T("DISCNUMBER")) || !strName.Compare(_T("DATE")) || !strName.Compare(_T("GENRE")) || !strName.Compare(_T("COMMENT"))) ) { continue; } // TRACE(_T("OGG %s %s\n"),strName,strValue); COggExt *oggExt = new COggExt(strName,strValue); ListBox_AddString(GetDlgItem(hDlg,IDC_LIST_VALUE),oggExt->Get1LineDisp()); ListBox_SetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),items,oggExt); items++; } } }
void ProjectConfigDialog::onButtonRemoveSearchPathClicked(void) { int index = ListBox_GetCurSel(GetDlgItem(m_hwndDialog, IDC_LIST_PACKAGE_SEARCH_PATHS)); if (index != LB_ERR) { ListBox_DeleteString(GetDlgItem(m_hwndDialog, IDC_LIST_PACKAGE_SEARCH_PATHS), index); m_project.setPackagePath(makeSearchPath().c_str()); } }
LOCAL void DragEnd(HWND hWindow) /***********************************************************************/ { // get the listbox data pointer, if we don't have one, get out LPLISTBOXDATA lpData = ListBox_GetData(hWindow); if (!lpData) return; // see if we ever started dragging if (lpData->fDragging) { // if we had a cursor, reset it if (lpData->hCursor) SetCursor(lpData->hOldCursor); // do the move if we successfully dragged if (lpData->fSuccess) { int nItem, iTopItem; TCHAR szString[256]; // save the top index, so we can reset it iTopItem = ListBox_GetTopIndex(hWindow); // turn of painting while working with list SetWindowRedraw(hWindow, FALSE); // save text of item ListBox_GetText(hWindow, lpData->iOldPos, szString); // delete the item ListBox_DeleteString(hWindow, lpData->iOldPos); // adjust index because of DeleteString int iNewPos = lpData->iNewPos; if (iNewPos > lpData->iOldPos) iNewPos--; // add the new string at the right spot nItem = ListBox_InsertString(hWindow, iNewPos, szString); // select the item we moved DWORD dwStyle = GetWindowLong(hWindow, GWL_STYLE); if (dwStyle & (LBS_MULTIPLESEL, LBS_EXTENDEDSEL)) ListBox_SetSel(hWindow, TRUE, nItem); else ListBox_SetCurSel(hWindow, nItem); // reset the top index ListBox_SetTopIndex(hWindow, iTopItem); // turn drawing back on SetWindowRedraw(hWindow, TRUE); // inform the dialog of the move FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow), hWindow, LBN_MOVEITEM, SendMessage); } } // turn off dragging lpData->fDragging = FALSE; KillTimer(hWindow, lpData->idTimer); }
void ClearLog(void) { HWND list = GetDlgItem(ghWndOutput, IDC_LST_OUTPUT); int count, i; count = ListBox_GetCount(list); for (i = 0; i < count; i++) { ListBox_DeleteString(list, 0); } }
VOID CUserControlList::Clear() { //удалить все элементы в списке while(ListBox_GetCount(mhWindow)) { //удалить элемент delete (CUserControlListElement*)ListBox_GetItemData(mhWindow,0); ListBox_DeleteString(mhWindow,0); } }
void CCreateBoundingWindow::OnClickDeleteButton() { int selectedIndex = ListBox_GetCurSel(mBoundingsList); if (selectedIndex == -1) return; CEditorScene* scene = CEditorScene::getInstance(); scene->DeleteBounding(selectedIndex); ListBox_DeleteString(mBoundingsList, selectedIndex); }
int w32g_refine_playlist(int *is_selected_removed) { int nremoved; int i, j1, j2, cursel; HWND hListBox; hListBox = playlist_box(); if(hListBox) cursel = ListBox_GetCurSel(hListBox); else cursel = -1; if(is_selected_removed != NULL) *is_selected_removed = 0; nremoved = 0; j1 = j2 = 0; while(j2 < playlist.nfiles) /* j1 <= j2 */ { if(playlist.list[j2].info->format < 0) { nremoved++; free(playlist.list[j2].filename); if(j2 == playlist.selected && is_selected_removed != NULL && !*is_selected_removed) { *is_selected_removed = 1; playlist.selected = j1; } if(j2 < playlist.selected) playlist.selected--; if(j2 < cursel) cursel--; } else { playlist.list[j1] = playlist.list[j2]; j1++; } j2++; } if(nremoved) { for(i = 0; i < nremoved; i++) ListBox_DeleteString(hListBox, --playlist.nfiles); if(cursel >= playlist.nfiles) cursel = playlist.nfiles - 1; if(cursel >= 0){ ListBox_SetCurSel(hListBox, cursel); SetNumListWnd(cursel,playlist.nfiles); } w32g_update_playlist(); } return nremoved; }
VOID CUserControlList::DeleteSelectedElement() { //получить выделенный элемент UINT ElementIndex=ListBox_GetCurSel(mhWindow); if(ElementIndex!=LB_ERR) { //удалить элемент delete (CUserControlListElement*)ListBox_GetItemData(mhWindow,ElementIndex); ListBox_DeleteString(mhWindow,ElementIndex); } }
void CCreateBoundingWindow::ShowMeshInfo(SMeshNodeInfo* info) { // clear item list int itemCount = ListBox_GetCount(mBoundingsList); for (int i = itemCount - 1; i >= 0; i--) { ListBox_DeleteString(mBoundingsList, i); } for (u32 i = 0; i < info->BoundingShapes.size(); i++) { SBoundingShape* shape = info->BoundingShapes[i]; int index = ListBox_AddString(mBoundingsList, shape->getShapeName()); ListBox_SetItemData(mBoundingsList, index, shape->getCategory()); } }
void InterfaceCheckChannels() { int num_items; channel_buffer_node *cb; HWND hwndList; while (IsNewChannelText()) { cb = GetChannelBuffer(); switch (cb->channel_id) { case CHANNEL_L : /* show channel text in status window */ SendDlgItemMessage(hwndMain,IDS_STATUS_WINDOW,SB_SETTEXT,0,(LPARAM)cb->buf); if (is_timer_pending) KillTimer(hwndMain,WIN_TIMER_ID); SetTimer(hwndMain,WIN_TIMER_ID,STATUS_CLEAR_TIME,NULL); hwndList = GetDlgItem(HWND_CHANNEL,IDC_LOG_LIST); break; case CHANNEL_E : hwndList = GetDlgItem(HWND_CHANNEL,IDC_ERROR_LIST); break; default: hwndList = GetDlgItem(HWND_CHANNEL,IDC_DEBUG_LIST); break; hwndList = NULL; break; } SendMessage(hwndList,WM_SETREDRAW,FALSE,0); num_items = ListBox_GetCount(hwndList); if (num_items >= CHANNEL_INTERFACE_LINES) ListBox_DeleteString(hwndList,0); ListBox_AddString(hwndList,cb->buf); ListBox_SetTopIndex(hwndList,max(0,num_items-1)); SendMessage(hwndList,WM_SETREDRAW,TRUE,0); DoneChannelBuffer(); } UpdateWindow(GetDlgItem(HWND_CHANNEL,IDC_LOG_LIST)); UpdateWindow(GetDlgItem(HWND_CHANNEL,IDC_ERROR_LIST)); UpdateWindow(GetDlgItem(HWND_CHANNEL,IDC_DEBUG_LIST)); }
void CCreateLightNodeWindow::OnClickDeleteButton() { int ret = MessageBoxA(mParentHwnd, "Are you sure to delete node?", "Delete Confirm", MB_OKCANCEL); if (ret == IDCANCEL) return; int id = GetSelectedItemId(); EditorScene* scene = EditorScene::getInstance(); if (scene->DeleteLight(id)) { int itemIndex = ListBox_GetCurSel(mLightNodesList); if (itemIndex != LB_ERR) { ListBox_DeleteString(mLightNodesList, itemIndex); } } }
void CInstanceInfoWindow::UpdateListBoxItems(u32 collectionId) { EditorScene* scene = EditorScene::getInstance(); std::vector<int> ids = scene->GetInstanceIdsInOneCollection(collectionId); int itemCount = ListBox_GetCount(mInstancesListBox); for (int i = itemCount - 1; i >= 0; i--) { ListBox_DeleteString(mInstancesListBox, i); } for (u32 i = 0; i < ids.size(); i++) { AddListBoxItem(ids[i]); } SetFocus(mParentHwnd); }
BOOL ListBox_DeleteAllStrings(HWND hwndListBox) { BOOL bSuccess = FALSE; int iCount = ListBox_GetSelCount(hwndListBox); LPINT lpiItems = (LPINT)_alloca(iCount * sizeof(INT)); ListBox_GetSelItems(hwndListBox, iCount, lpiItems); SetWindowRedraw(hwndListBox, FALSE); for ( ; iCount > 0; iCount--) { if (ListBox_DeleteString(hwndListBox, lpiItems[iCount - 1]) != LB_ERR) bSuccess = TRUE; } SetWindowRedraw(hwndListBox, TRUE); return (bSuccess); }
void w32g_clear_playlist(void) { HWND hListBox; hListBox = playlist_box(); while(playlist.nfiles > 0) { playlist.nfiles--; free(playlist.list[playlist.nfiles].filename); #if 0 if(hListBox) ListBox_DeleteString(hListBox, playlist.nfiles); #endif } // LB_RESETCONTENT if(hListBox) ListBox_ResetContent(hListBox); playlist.selected = 0; SetNumListWnd(0,0); }
void plResponderProc::RemoveCurCommand() { int idx = ListBox_GetCurSel(fhList); if (idx == LB_ERR) return; // Destroy the current rollup, since it's this guy IRemoveCmdRollups(); // Delete all traces of this command fStatePB->Delete(kStateCmdParams, idx, 1); fStatePB->Delete(kStateCmdWait, idx, 1); fStatePB->Delete(kStateCmdEnabled, idx, 1); ListBox_DeleteString(fhList, idx); // Patch the wait commands ResponderWait::CmdRemoved(fStatePB, idx); fCmdIdx = -1; }
void CInstanceInfoWindow::OnClickDeleteButton() { int id = GetSelectedListItemId(mInstancesListBox); if (id == -1) return; int ret = MessageBoxA(mParentHwnd, "Are you sure to delete instance?", "Delete Confirm", MB_OKCANCEL); if (ret == IDCANCEL) return; EditorScene* scene = EditorScene::getInstance(); scene->DeleteNode(id); scene->CancelSelectObject(); int itemIndex = ListBox_GetCurSel(mInstancesListBox); if (itemIndex != LB_ERR) { ListBox_DeleteString(mInstancesListBox, itemIndex); } }
void FileChildWindow::collapse_entry(Pane* pane, Entry* dir) { int idx = ListBox_FindItemData(*pane, 0, dir); SendMessage(*pane, WM_SETREDRAW, FALSE, 0); //ShowWindow(*pane, SW_HIDE); // hide sub entries for(;;) { LRESULT res = ListBox_GetItemData(*pane, idx+1); Entry* sub = (Entry*) res; if (res==LB_ERR || !sub || sub->_level<=dir->_level) break; ListBox_DeleteString(*pane, idx+1); } dir->_expanded = false; SendMessage(*pane, WM_SETREDRAW, TRUE, 0); //ShowWindow(*pane, SW_SHOW); }
/* * MailDeleteMessage: Delete the mail message with the given number. * Return True on success. */ Bool MailDeleteMessage(int number) { char filename[MAX_PATH + FILENAME_MAX]; int index; if ((index = MailFindIndex(number)) == -1) { debug(("Message number not found to delete\n")); return False; } ListBox_GetText(hMsgList, index, filename); if (unlink(filename) != 0) { ClientError(hInst, hReadMailDlg, IDS_CANTDELETEMAIL, filename); return False; } ListBox_DeleteString(hMsgList, index); return True; }
void perform(HWND hDlg, HWND hList, HWND hEditList,Plane::PlaneDirection direction //,CountPlanesFunc cpf,LandOrLiftPlanesFunc lolpf, ) { Plane * plane = gestor->criarAviaoPara(direction); ListBox_AddString(hList,plane->GetName()); //_itot_s(cpf(),buffer,sizeof(_TCHAR)*MAX_BUFFER,10); loadIntoBufferPlanesCount(direction); Edit_SetText(hEditList,buffer); plane = executeLandOrListFunction(direction); EnterCriticalSection(&csDelFromLB); ListBox_DeleteString(hList,ListBox_FindStringExact(hList,0,plane->GetName())); LeaveCriticalSection(&csDelFromLB); //_itot_s(cpf(),buffer,sizeof(_TCHAR)*MAX_BUFFER,10); loadIntoBufferPlanesCount(direction); Edit_SetText(hEditList,buffer); if(!(plane->terminateQuickly())) { INT * animationEditTexts = getAnimationEditText(plane->_idLane); if(plane->GetDirection()==Plane::LAND) { for (int i=0; i < 26; ++i) { doAnimation(plane,hDlg,animationEditTexts[i]); } } else if(plane->GetDirection()==Plane::LIFTOFF) { for(int i = 25; i>=0;--i) { doAnimation(plane,hDlg,animationEditTexts[i]); } } gestor->libertarPista(plane); } }
int w32g_delete_playlist(int pos) { int i; HWND hListBox; if(!(hListBox = playlist_box())) return 0; if(pos >= playlist.nfiles) return 0; #ifdef W32G_RANDOM_IS_SHUFFLE w32g_shuffle_playlist_delete(pos); #endif ListBox_DeleteString(hListBox, pos); free(playlist.list[pos].filename); playlist.nfiles--; for(i = pos; i < playlist.nfiles; i++) playlist.list[i] = playlist.list[i + 1]; if(pos < playlist.selected || pos == playlist.nfiles) { playlist.selected--; if(playlist.selected < 0){ playlist.selected = 0; SetNumListWnd(playlist.selected,playlist.nfiles); } else w32g_update_playlist_pos(playlist.selected); } if(playlist.nfiles > 0) { if(pos == playlist.nfiles) pos--; ListBox_SetCurSel(hListBox, pos); SetNumListWnd(pos,playlist.nfiles); } return 1; }
void plResponderProc::ICmdRightClick(HWND hCmdList) { // Get the position of the cursor in screen and tree client coords POINT point, localPoint; GetCursorPos(&point); localPoint = point; ScreenToClient(hCmdList, &localPoint); LRESULT res = SendMessage(hCmdList, LB_ITEMFROMPOINT, 0, MAKELPARAM(localPoint.x, localPoint.y)); WORD index = LOWORD(res); if (index == WORD(LB_ERR)) return; RECT rect; SendMessage(hCmdList, LB_GETITEMRECT, index, (LPARAM)&rect); // Make sure we're actually ON an item, LB_ITEMFROMPOINT get the closest instead of exact if (localPoint.y >= rect.top && localPoint.y <= rect.bottom) { BOOL enabled = fStatePB->GetInt(kStateCmdEnabled, 0, index); HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, 1, enabled ? "Disable" : "Enable"); SetForegroundWindow(fhDlg); int sel = TrackPopupMenu(hMenu, TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, 0, fhDlg, NULL); if (sel == 1) { fStatePB->SetValue(kStateCmdEnabled, 0, !enabled, index); ListBox_DeleteString(hCmdList, index); ListBox_InsertString(hCmdList, index, GetCommandName(index)); } DestroyMenu(hMenu); } }
void FileChildWindow::scan_entry(Entry* entry) { CONTEXT("FileChildWindow::scan_entry()"); int idx = ListBox_GetCurSel(_left_hwnd); // delete sub entries in left pane for(;;) { LRESULT res = ListBox_GetItemData(_left_hwnd, idx+1); Entry* sub = (Entry*) res; if (res==LB_ERR || !sub || sub->_level<=entry->_level) break; ListBox_DeleteString(_left_hwnd, idx+1); } // empty right pane ListBox_ResetContent(_right_hwnd); // release memory entry->free_subentries(); entry->_expanded = false; // read contents from disk entry->read_directory_base(_root._sort_order); ///@todo use modifyable sort order instead of fixed file system default // insert found entries in right pane HiddenWindow hide(_right_hwnd); _right->insert_entries(entry->_down); _right->calc_widths(false); _right->set_header(); _header_wdths_ok = false; }
INT_PTR CDialogManage::CTabThemes::OnCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX: { BOOL state = !(Button_GetCheck((HWND)lParam) == BST_CHECKED); HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_UNUSEDSKINS_CHECKBOX); EnableWindow(item, state); Button_SetCheck(item, BST_UNCHECKED); item = GetDlgItem(m_Window, IDC_MANAGETHEMES_WALLPAPER_CHECKBOX); EnableWindow(item, state); Button_SetCheck(item, BST_UNCHECKED); } break; case IDC_MANAGETHEMES_NAME_TEXT: if (HIWORD(wParam) == EN_CHANGE) { WCHAR buffer[32]; int len = Edit_GetText((HWND)lParam, buffer, 32); // Disable save button if no text or if backup BOOL state = (len > 0 && _wcsicmp(buffer, L"@Backup") != 0); EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_SAVE_BUTTON), state); } break; case IDC_MANAGETHEMES_LIST: if (HIWORD(wParam) == LBN_SELCHANGE) { // Ignore clicks that don't hit items if (ListBox_GetCurSel((HWND)lParam) != LB_ERR) { HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LOAD_BUTTON); EnableWindow(item, TRUE); item = GetDlgItem(m_Window, IDC_MANAGETHEMES_DELETE_BUTTON); EnableWindow(item, TRUE); item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EDIT_BUTTON); EnableWindow(item, TRUE); const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes(); item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST); int sel = ListBox_GetCurSel(item); item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT); Edit_SetText(item, themes[sel].c_str()); } } break; case IDC_MANAGETHEMES_SAVE_BUTTON: { WCHAR buffer[MAX_PATH]; HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_NAME_TEXT); Edit_GetText(item, buffer, MAX_PATH); std::wstring theme = buffer; std::wstring path = Rainmeter->GetThemePath(); CreateDirectory(path.c_str(), 0); path += theme; bool alreadyExists = (_waccess(path.c_str(), 0) != -1); if (alreadyExists) { std::wstring text = GetFormattedString(ID_STR_THEMEALREADYEXISTS, theme.c_str()); if (Rainmeter->ShowMessage(m_Window, text.c_str(), MB_ICONWARNING | MB_YESNO) != IDYES) { // Cancel break; } } else { // Make sure path exists CreateDirectory(path.c_str(), NULL); } path += L"\\Rainmeter.thm"; item = GetDlgItem(m_Window, IDC_MANAGETHEMES_EMPTYTHEME_CHECKBOX); if (Button_GetCheck(item) != BST_CHECKED) { if (!CSystem::CopyFiles(Rainmeter->GetIniFile(), path)) { std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str()); Rainmeter->ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR); break; } // Exclude unused skins item = GetDlgItem(m_Window, IDC_MANAGETHEMES_UNUSEDSKINS_CHECKBOX); if (Button_GetCheck(item) == BST_CHECKED) { CConfigParser parser; parser.Initialize(path); // Remove sections with Active=0 std::list<std::wstring>::const_iterator iter = parser.GetSections().begin(); for ( ; iter != parser.GetSections().end(); ++iter) { if (parser.GetValue(*iter, L"Active", L"") == L"0") { WritePrivateProfileString((*iter).c_str(), NULL, NULL, path.c_str()); } } } // Save wallpaper item = GetDlgItem(m_Window, IDC_MANAGETHEMES_WALLPAPER_CHECKBOX); if (Button_GetCheck(item) == BST_CHECKED) { // Get current wallpaper if (SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, &buffer, 0)) { std::wstring::size_type pos = path.find_last_of(L'\\'); path.replace(pos + 1, path.length() - pos - 1, L"RainThemes.bmp"); CSystem::CopyFiles((std::wstring)buffer, path); } } } else { // Create empty theme HANDLE file = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (file == INVALID_HANDLE_VALUE) { std::wstring text = GetFormattedString(ID_STR_THEMESAVEFAIL, path.c_str()); Rainmeter->ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONERROR); break; } CloseHandle(file); } if (!alreadyExists) { item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST); ListBox_AddString(item, theme.c_str()); Rainmeter->ScanForThemes(); } } break; case IDC_MANAGETHEMES_LOAD_BUTTON: { HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST); int sel = ListBox_GetCurSel(item); Rainmeter->LoadTheme(Rainmeter->m_Themes[sel]); } break; case IDC_MANAGETHEMES_EDIT_BUTTON: { HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST); int sel = ListBox_GetCurSel(item); const std::vector<std::wstring>& themes = Rainmeter->GetAllThemes(); std::wstring args = Rainmeter->GetThemePath(); args += themes[sel]; args += L"\\Rainmeter.thm"; RunFile(Rainmeter->GetSkinEditor().c_str(), args.c_str()); } break; case IDC_MANAGETHEMES_DELETE_BUTTON: { HWND item = GetDlgItem(m_Window, IDC_MANAGETHEMES_LIST); int sel = ListBox_GetCurSel(item); std::vector<std::wstring>& themes = const_cast<std::vector<std::wstring>&>(Rainmeter->GetAllThemes()); std::wstring text = GetFormattedString(ID_STR_THEMEDELETE, themes[sel].c_str()); if (Rainmeter->ShowMessage(m_Window, text.c_str(), MB_ICONQUESTION | MB_YESNO) != IDYES) { // Cancel break; } std::wstring folder = Rainmeter->GetThemePath(); folder += themes[sel]; if (CSystem::RemoveFolder(folder)) { ListBox_DeleteString(item, sel); // Remove theme from vector std::vector<std::wstring>::iterator iter = themes.begin(); for ( ; iter != themes.end(); ++iter) { if (wcscmp(themes[sel].c_str(), (*iter).c_str()) == 0) { themes.erase(iter); break; } } EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_LOAD_BUTTON), FALSE); EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_DELETE_BUTTON), FALSE); EnableWindow(GetDlgItem(m_Window, IDC_MANAGETHEMES_EDIT_BUTTON), FALSE); } } break; default: return 1; } return 0; }
VOID ViewMarks_OnCommand( HWND hwnd, INT id, HWND hwndCtrl, UINT codeNotify ) { INT i, j; HWND hwndList; LRESULT lResult; switch(id) { case IDC_MARK_LIST: if ( codeNotify == LBN_SELCHANGE ) { lResult = ListBox_GetCurSel( hwndCtrl ); if ( lResult >= 0 && lResult < pLevel->nMarks ) { pLevel->nLastMark = (INT)lResult; } } break; case IDC_NEW_MARK: i = pLevel->nMarks; if (i == MAX_MARKS) { MsgBox( hwnd, MB_ICONEXCLAMATION, "The limit of %d marks has been reached.", MAX_MARKS ); break; } szMarkName[0] = '\0'; wsprintf(szMarkX, "%ld", pLevel->view_x); wsprintf(szMarkY, "%ld", pLevel->view_y); wsprintf(szMarkZ, "%ld", pLevel->view_z); DoubleToString(szMarkRotation, pLevel->view_rotation * 180.0 / PI, 2); DoubleToString(szMarkElevation, pLevel->view_elevation * 180.0 / PI, 2); if (EditMarkDialog(hwnd) == IDCANCEL) { break; } if (!szMarkName[0]) { break; } hwndList = GetDlgItem(hwnd, IDC_MARK_LIST); ListBox_AddString(hwndList, szMarkName); _fstrcpy(pLevel->pMarkData[i].mark_name, szMarkName); pLevel->pMarkData[i].x = atol(szMarkX); pLevel->pMarkData[i].y = atol(szMarkY); pLevel->pMarkData[i].z = atol(szMarkZ); pLevel->pMarkData[i].rotation = atof(szMarkRotation) * PI / 180.0; pLevel->pMarkData[i].elevation = atof(szMarkElevation) * PI / 180.0; ++pLevel->nMarks; ListBox_SetCurSel(hwndList, i); pLevel->nLastMark = i; bChange = TRUE; break; case IDC_DELETE_MARK: hwndList = GetDlgItem( hwnd, IDC_MARK_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < pLevel->nMarks ) { i = (INT)lResult; DeleteMark( pLevel, i ); ListBox_DeleteString( hwndList, i ); if ( i == 0 ) ListBox_SetCurSel( hwndList, 0 ); else ListBox_SetCurSel( hwndList, i - 1 ); bChange = TRUE; } break; case IDC_EDIT_MARK: hwndList = GetDlgItem( hwnd, IDC_MARK_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < pLevel->nMarks ) { i = (INT)lResult; _fstrcpy(szMarkName, pLevel->pMarkData[i].mark_name); wsprintf(szMarkX, "%ld", pLevel->pMarkData[i].x); wsprintf(szMarkY, "%ld", pLevel->pMarkData[i].y); wsprintf(szMarkZ, "%ld", pLevel->pMarkData[i].z); DoubleToString(szMarkRotation, pLevel->pMarkData[i].rotation * 180.0 / PI, 2); DoubleToString(szMarkElevation, pLevel->pMarkData[i].elevation * 180.0 / PI, 2); if ( EditMarkDialog( hwnd ) == IDCANCEL ) { break; } if ( !szMarkName[0] ) { break; } _fstrcpy( pLevel->pMarkData[i].mark_name, szMarkName ); pLevel->pMarkData[i].x = atol(szMarkX); pLevel->pMarkData[i].y = atol(szMarkY); pLevel->pMarkData[i].z = atol(szMarkZ); pLevel->pMarkData[i].rotation = atof(szMarkRotation) * PI / 180.0; pLevel->pMarkData[i].elevation = atof(szMarkElevation) * PI / 180.0; j = ListBox_GetTopIndex(hwndList); ListBox_ResetContent(hwndList); for( i = 0; i < pLevel->nMarks; ++i ) { ListBox_AddString( hwndList, pLevel->pMarkData[i].mark_name ); } ListBox_SetTopIndex( hwndList, j ); ListBox_SetCurSel( hwndList, (INT)lResult ); bChange = TRUE; } break; case IDC_GO_TO_MARK: hwndList = GetDlgItem( hwnd, IDC_MARK_LIST ); lResult = ListBox_GetCurSel( hwndList ); if ( lResult >= 0 && lResult < pLevel->nMarks ) { i = (INT)lResult; pLevel->view_x = pLevel->pMarkData[i].x; pLevel->view_y = pLevel->pMarkData[i].y; pLevel->view_z = pLevel->pMarkData[i].z; pLevel->view_rotation = pLevel->pMarkData[i].rotation; pLevel->view_elevation = pLevel->pMarkData[i].elevation; Object_ViewStatusUpdate(hParent, po); Object_ViewChanged(hParent, po); bChange = TRUE; } break; case IDOK: case IDCANCEL: if ( hPalCommon ) { DeleteObject( hPalCommon ); hPalCommon = NULL; } EndDialog( hwnd, id ); break; } } // ViewMarks_OnCommand
LRESULT CALLBACK CartDBFilesDlg(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { char *p,*tmp,*str = (char*)(LONG_PTR)GetWindowLongPtr(hwnd,GWLP_USERDATA); int n,i; switch(message) { case WM_INITDIALOG: SetWindowLongPtr(hwnd,GWLP_USERDATA,(LONG)(LONG_PTR)lParam); str = strdup((char*)lParam); p = strtok(str,";"); while(p) { tmp = strdup(p); ListBox_AddString(GetDlgItem(hwnd,IDC_FILELIST),str_eatwhitespace(tmp)); free(tmp); p = strtok(0,";"); } free(str); EnableWindow(GetDlgItem(hwnd,IDC_DELETEBUTTON),FALSE); return(TRUE); case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_FILELIST: switch(HIWORD(wParam)) { case LBN_DBLCLK: tmp = (char*)mem_alloc(1024); n = ListBox_GetCurSel(GetDlgItem(hwnd,IDC_FILELIST)); ListBox_GetText(GetDlgItem(hwnd,IDC_FILELIST),n,tmp); tmp = (char*)DialogBoxParam(hInst,(LPCTSTR)IDD_FILEEDIT,hwnd,(DLGPROC)FileEditDlg,(LPARAM)(char*)tmp); if(tmp) { ListBox_DeleteString(GetDlgItem(hwnd,IDC_FILELIST),n); ListBox_InsertString(GetDlgItem(hwnd,IDC_FILELIST),n,tmp); mem_free(tmp); } return(TRUE); case LBN_SELCHANGE: EnableWindow(GetDlgItem(hwnd,IDC_DELETEBUTTON),TRUE); return(TRUE); case LBN_SELCANCEL: EnableWindow(GetDlgItem(hwnd,IDC_DELETEBUTTON),FALSE); return(TRUE); } break; case IDC_ADDBUTTON: tmp = (char*)DialogBoxParam(hInst,(LPCTSTR)IDD_FILEEDIT,hwnd,(DLGPROC)FileEditDlg,0); if(tmp) { ListBox_AddString(GetDlgItem(hwnd,IDC_FILELIST),tmp); mem_free(tmp); } return(TRUE); case IDC_DELETEBUTTON: n = ListBox_GetCurSel(GetDlgItem(hwnd,IDC_FILELIST)); if(n != LB_ERR) ListBox_DeleteString(GetDlgItem(hwnd,IDC_FILELIST),n); return(TRUE); case IDOK: n = ListBox_GetCount(GetDlgItem(hwnd,IDC_FILELIST)); strcpy(str,""); tmp = (char*)mem_alloc(1024); for(i=0;i<n;i++) { if(i) strcat(str," ; "); ListBox_GetText(GetDlgItem(hwnd,IDC_FILELIST),i,tmp); strcat(str,tmp); } mem_free(tmp); EndDialog(hwnd,(INT_PTR)str); return(TRUE); case IDCANCEL: EndDialog(hwnd,(INT_PTR)NULL); return(TRUE); } break; case WM_DESTROY: break; } return(FALSE); }