Hi During the writing of my program I encountered a challenge (not a very big one). I want my program to have a "Recent Files" menu. You know, that list of the most recent files the user has opened/saved. It sounds easy, but it's not really that easy since I need to store full paths+filenames; manage the menu which involves calculating its width (I don't want the menu to take up the whole screen just because the filename is long). I need to shift the items accordingly to the use of the files: the most recent goes to the top the rest get shifted downwards (a process which involves shifting large strings, there's probably a better way, but that's what I figured out in the meantime) Now what if the file opened is already on the list? It has to go to the top and the rest of the items simply to shift downwards, without the least recent filename disappearing from the menu. If the filename is too long its name in the menu needs to be cut to the appropriate width (graphical, not in characters, since the font in the menu is not size- fixed, so there: more calculations) and those three dots need to be added to the end. I want each item to have a keyboard shortcut in a form of index: 1,2,3,4... etc. There's a little bit more to it, but I'll settle for this. As you see it's a pretty "big" thing since we program in ASM. My program is complete.. I wrote most of the mentioned above, but in a very not-optimized way. I would like to write a library which will handle all of that, and the programmers would only have to interact with it: telling how many items they want on the menu, the width of the menu, the addresses of the buffers to store the filenames and the menu item names. And then of course I want to distribute this library. Now my questions are. Is there already a FREE library like that availabe (written of course in ASM)? If there is I'd be glad if you appointed me to it. If you haven't heard of such thing I'd be glad if you could appoint me to some docs, that you think I could use to make this lib in the most perfect way (managing menus is supposed to be a pretty common thing, but please don't send me to that, I need docs that could help me figure out how to organize all the strings, maybe not strings, just create index to each menu item and shift that, you get my drift) And last but not least. Is there a strong point in making this thing in a DLL? (which will contain only this baby). Thanks for reading this :) RingZer0
Posted on 2001-03-30 15:27:00 by RingZer0
well, your method seems complicated. Here is my method. I cannot guarantee that it's the best but it is straightforward and easy to implement (for me). - I store the recent file list in the registry. I create a subkey for them so that I can delete them all in a single call to RegDeleteKey - When my app starts, it reads all the entries in that subkey and stores them in a linked list: the most recent files are at the head of the linked list. - When the user clicks on the "File" menu, my app deletes ALL the recent file items in the menu and appends them again based on their order in the linked list. - When the user opens a file, my app checks whether the file is already in the linked list. If it is, that node is moved to the top (the linked list must be two-way one). If not, the app creates a new node and puts it at the head of the linked list. - When the app exits, it deletes the subkey in the registry,create the subkey again and writes the file names in the linked list in the subkey.
Posted on 2001-03-30 18:34:00 by Iczelion
Thanks for the reply, Iczelion. No one's gonna argue with your method cuz you're the man. It's the method I'm probably gonna use.. But my original question was really if I should write a library which will do all of that. The programmer would only have to make a call to it and pass all the parameters in a structure and then call one single and the same function each time a file is opened, saved etc.. I just sorta want to take off the burden from myself since nearly all of my future programs will contain a "Recent Files" menu and coding the logic each time is plain crazy. If the lib turns out well, I will distribute it. So once again.. Is there already a FREE (asm) library like that? I don't want to code something that already exists. And is there a point in making this in a DLL cuz if it's good and a lot of ppl start using it, it might save some memory if 2 different apps that use it run at the same time. (I figure it's gonna take up around 8Kb). Just tell me what you think. RingZer0
Posted on 2001-03-31 06:30:00 by RingZer0
Sorry for the last post: I read your post in a hurry and miss your question completely. It would be a good idea to write routines to do "recent files" list. I personally don't like lots of small DLLs floating around in my apps. So if it were I, I would code it as a static lib: the user can use it as it is or he can put it into his own DLL.
Posted on 2001-03-31 07:35:00 by Iczelion
That was all I really needed to hear, IcZelion. Thanks, man :) Will do it your way :) RingZer0
Posted on 2001-03-31 18:36:00 by RingZer0