I have run into a block trying to figure out how I can load specific files from a directory into a menu and click them to launch to files. I have no problems loading my menu up, the problem comes in with the Windows Processing.
Basically I increment an integer to add files sequentially, like so...
mnuFiles above being a globally defined as 460 and the function IsValidFile verifies that the file is not a directory.Code:void loadMenu(HMENU hMenu) { char *RecentDocs; RecentDocs = GetRecentDocs(); strcat(RecentDocs, "\\*.lnk"); int iMenuCount = 0, bMenu = 0; HANDLE hFile = 0; WIN32_FIND_DATA wfs; hFile = FindFirstFile(RecentDocs, &wfs); DWORD dwError; iMenuCount = GetMenuItemCount(hMenu); while (iMenuCount > -1) { RemoveMenu(hMenu, iMenuCount, MF_BYPOSITION); iMenuCount--; } if (hFile != INVALID_HANDLE_VALUE && hFile != NULL) { if (IsValidFile(wfs.cFileName) == 1) { bMenu++; AppendMenu(hMenu, MF_STRING, (mnuFiles + bMenu), left(wfs.cFileName, strlen(wfs.cFileName) - 4)); } while (FindNextFile(hFile, &wfs) != 0) { if (IsValidFile(wfs.cFileName) == 1) { bMenu++; AppendMenu(hMenu, MF_STRING, (mnuFiles + bMenu), left(wfs.cFileName, strlen(wfs.cFileName) - 4)); } } dwError = GetLastError(); if (dwError == ERROR_NO_MORE_FILES) { FindClose(hFile); } } if (bMenu == 0) { AppendMenu(hMenu, MF_STRING | MF_GRAYED, 0, "(Empty)"); } }
The problem is now how I can get the menu text information (so from there I can create the file path and launch the file). Trying to use GetMenuString has caused crashes.
I can't find if the menu id information is maybe in the lparam part of the processing.
Any insight would be greatly appreciated.



LinkBack URL
About LinkBacks


