LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

recent file pulldown menu

Is there a reasonable method of coding a "most recently used file" pull
down menu. All the ways I can think of a fairly complex.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
0 Kudos
Message 1 of 3
(3,120 Views)
Hi,

There is a complicated example in the Sample CVI files (I can't remember the exact path). However, I have successfully used the 'List' functions (either toolbox or utility functions as I recall) to implement a recent files list, after a fashion.  The basic idea was as follows:

struct MenuList
      {
       ListType FilePathList;  // full file path
       ListType FileMenuList;  // abbreviated path for display on menu
       ListType FileMenuID;       // identifier for each menu entry of full and abbreviated paths
      }     RFL;

char pathname[MAX_FILENAME_LEN], display_path[MAX_PATHNAME_LEN];
int entry_ID;
static int prev_entry_ID; // (use ListGetItem for this)

//  Break up 'pathname' using pointer manipulation, strcpy, strstr, strcat, or strtok, etc. e.g. C:\Data...\test.dat
....
// add to menu and assign a custom callback function (e.g. 'OpenRecentFile'), which uses RFL structure for information on path...
 entry_ID = NewMenuItem (Menubar, MenuID, display_path, prev_entry_ID, 0, OpenRecentFile, RFL); 
 SetMenuBarAttribute (Menubar, entry_ID, ATTR_CHECKED, TRUE); // optional check mark

Then use...
ListInsertItem (RFL.FilePathList, pathname, FRONT_OF_LIST);     
ListInsertItem (RFL.FileMenuList, display_path, FRONT_OF_LIST);  
ListInsertItem (RFL.FileMenuID, &entry_ID, FRONT_OF_LIST); 

I also used ListGetPtrToItem, ListNumItems, ListInsertItem and ListRemoveItem.  If you read the help info for these, their application should make sense.  'Normal' windows-based applications save their recent file list in the Windows registry, but I avoided this by simply writing all strings to a text file in the application's directory. (much simpler and safer for apps that may not be installed with an installation program!)

John.
0 Kudos
Message 2 of 3
(3,011 Views)
Hello,
 
You might also be looking for something like the Path Control (toolslib\custctrl\pathctrl.fp).  The path control keeps a history of the paths you enter in the control and you can press the up/down keys to navigate through the list.
 
Hope that helps.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 3 of 3
(3,000 Views)