------------------------------------------------------------------------------- Recover the file history -------------------------------------------------------------------------------
| 740 | // Recover the file history |
| 741 | //------------------------------------------------------------------------------- |
| 742 | void LoadHistory() { |
| 743 | g_aPreviousFiles.resize(AI_VIEW_NUM_RECENT_FILES); |
| 744 | |
| 745 | char szFileName[MAX_PATH]; |
| 746 | |
| 747 | for (unsigned int i = 0; i < AI_VIEW_NUM_RECENT_FILES;++i) { |
| 748 | char szName[66]; |
| 749 | sprintf(szName,"Recent%i",i+1); |
| 750 | |
| 751 | DWORD dwTemp = MAX_PATH; |
| 752 | |
| 753 | szFileName[0] ='\0'; |
| 754 | if(ERROR_SUCCESS == RegQueryValueEx(g_hRegistry,szName,nullptr,nullptr, |
| 755 | (BYTE*)szFileName,&dwTemp)) { |
| 756 | g_aPreviousFiles[i] = std::string(szFileName); |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | // add sub items for all recent files |
| 761 | g_hHistoryMenu = CreateMenu(); |
| 762 | for (int i = AI_VIEW_NUM_RECENT_FILES-1; i >= 0;--i) { |
| 763 | const char* szText = g_aPreviousFiles[i].c_str(); |
| 764 | UINT iFlags = 0; |
| 765 | if ('\0' == *szText) { |
| 766 | szText = "<empty>"; |
| 767 | iFlags = MF_GRAYED | MF_DISABLED; |
| 768 | } |
| 769 | AppendMenu(g_hHistoryMenu,MF_STRING | iFlags,AI_VIEW_RECENT_FILE_ID(i),szText); |
| 770 | } |
| 771 | |
| 772 | ModifyMenu(GetMenu(g_hDlg),ID_VIEWER_RECENTFILES,MF_BYCOMMAND | MF_POPUP, |
| 773 | (UINT_PTR)g_hHistoryMenu,"Recent files"); |
| 774 | } |
| 775 | |
| 776 | //------------------------------------------------------------------------------- |
| 777 | // Clear the file history |