From ce279995decfb03e6ac02ef8d8c0078d8898de93 Mon Sep 17 00:00:00 2001 From: gocha Date: Fri, 25 Sep 2009 13:30:04 +0000 Subject: [PATCH] ramwatch: add more (ListView_GetSelectionMark() != -1) checks --- desmume/src/windows/ramwatch.cpp | 38 +++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/desmume/src/windows/ramwatch.cpp b/desmume/src/windows/ramwatch.cpp index 1945cbf82..813d2cbcc 100644 --- a/desmume/src/windows/ramwatch.cpp +++ b/desmume/src/windows/ramwatch.cpp @@ -965,15 +965,21 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam return true; case IDC_C_WATCH_REMOVE: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); - RemoveWatch(watchIndex); - ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); - RWfileChanged=true; - SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + if(watchIndex != -1) + { + RemoveWatch(watchIndex); + ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); + RWfileChanged=true; + SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + } return true; case IDC_C_WATCH_EDIT: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); - DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex); - SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + if(watchIndex != -1) + { + DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex); + SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + } return true; case IDC_C_WATCH: rswatches[WatchCount].Address = rswatches[WatchCount].WrongEndian = 0; @@ -984,12 +990,15 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam return true; case IDC_C_WATCH_DUPLICATE: watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); - rswatches[WatchCount].Address = rswatches[watchIndex].Address; - rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian; - rswatches[WatchCount].Size = rswatches[watchIndex].Size; - rswatches[WatchCount].Type = rswatches[watchIndex].Type; - DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); - SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + if(watchIndex != -1) + { + rswatches[WatchCount].Address = rswatches[watchIndex].Address; + rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian; + rswatches[WatchCount].Size = rswatches[watchIndex].Size; + rswatches[WatchCount].Type = rswatches[watchIndex].Type; + DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); + SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + } return true; case IDC_C_WATCH_UP: { @@ -1038,7 +1047,10 @@ LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam case IDC_C_ADDCHEAT: { watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)) | (1 << 24); -// DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITCHEAT), hDlg, (DLGPROC) EditCheatProc,(LPARAM) searchIndex); //TODO: made a IDD_EDITCHEAT dialog, and EditCheatProc (are they in GENS?) and integrate into cheats system + if(watchIndex != -1) + { +// DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITCHEAT), hDlg, (DLGPROC) EditCheatProc,(LPARAM) searchIndex); //TODO: made a IDD_EDITCHEAT dialog, and EditCheatProc (are they in GENS?) and integrate into cheats system + } break; } case IDCANCEL: