diff --git a/changelog.txt b/changelog.txt index ef0ff145..b58cc0a2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,4 @@ +23-may-2009 - adelikat - win32 - Added a remove recent item function and hooked it up to memwatch recent menu, now if a bad recent item is clicked, the user has a choice to remove it from the list 23-may-2009 - adelikat - win32 - Load Last Movie context menu item added 23-may-2009 - adelikat - win32 - Recent Movie Menu added 22-may-2009 - adelikat - win32 - "Disable screen saver" gui option now also diables the monitor powersave diff --git a/src/drivers/win/memwatch.cpp b/src/drivers/win/memwatch.cpp index def8b178..9478c786 100644 --- a/src/drivers/win/memwatch.cpp +++ b/src/drivers/win/memwatch.cpp @@ -65,6 +65,7 @@ char *memw_recent_files[] = { 0 ,0 ,0 ,0 ,0 }; const unsigned int MEMW_MENU_FIRST_RECENT_FILE = 600; const unsigned int MEMW_MAX_NUMBER_OF_RECENT_FILES = sizeof(memw_recent_files)/sizeof(*memw_recent_files); +extern void RemoveRecentItem(unsigned int which, char**bufferArray, const unsigned int MAX); //For removing erroneous recent files //Ram change monitor globals----------------------------------- bool RamChangeInitialize = false; //Set true during memw WM_INIT @@ -629,8 +630,14 @@ void OpenMemwatchRecentFile(int memwRFileNumber) fileChanged = false; //Flag that the memwatch file has not been changed since last save } else //Opening fp failed - MessageBox(hwndMemWatch,"Error: Could not open recent file", "Memory Watch Recent File", MB_OK); - //TODO: Remove this file from the recent list + { + int result = MessageBox(hwndMemWatch,"Remove from list?", "Could Not Open Recent File", MB_YESNO); + if (result == IDYES) + { + RemoveRecentItem(memwRFileNumber, memw_recent_files, MEMW_MAX_NUMBER_OF_RECENT_FILES); + UpdateMemw_RMenu(memwrecentmenu, memw_recent_files, ID_FILE_RECENT, MEMW_MENU_FIRST_RECENT_FILE); + } + } } bool CloseMemoryWatch() diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 3d7c07a1..a36265bb 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -500,6 +500,39 @@ void UpdateContextMenuItems(HMENU context, int whichContext) } } + +//adelikat: This removes a recent menu item from any recent menu, and shrinks the list accordingly +//The update recent menu function will need to be run after this +void RemoveRecentItem(unsigned int which, char**bufferArray, const unsigned int MAX) +{ + //which = array item to remove + //buffer = char array of the recent menu + //MAX = max number of array items + + //Just in case + if (which >= MAX) + return; + + //Remove the item + if(bufferArray[which]) + { + free(bufferArray[which]); + } + + //If the item is not the last one in the list, shift the remaining ones up + if (which < (MAX-1)) + { + //Move the remaining items up + for(unsigned int x = which+1; x < MAX; x++) + { + bufferArray[x-1] = bufferArray[x]; //Shift each remaining item up by 1 + } + } + + bufferArray[MAX-1] = 0; //Clear out the last item since it is empty now no matter what +} + + /// Updates recent files / recent directories menu /// @param menu Menu handle of the main window's menu /// @param strs Strings to add to the menu