Re: making a very simple menu in DOS
- From: John <John@xxxxxxxxxxx>
- Date: Wed, 01 Feb 2006 00:57:39 GMT
Tim Ricard wrote:
I originally posted this in comp.lang.c but they recommended I ask here:
Good evening,
I was thinking about making a very simple DOS based (console) menu for a project that i am working on, but I have no idea where to start for something like this. I don't want a real complicated menu, just a title and about three options. I will add more stuff once I know what it is that I am doing. The program will also be written in C.
Just to clarify, I am not talking about making a printf/fscanf menu. I
want to make a menu that has static information on the screen. I want
to make a simple shell where pressing the cursor can allow for you to
scroll over top of the various menu items and *enter* will select the
desired item.
Thanks in advance
Tim
Well ... You need to know exactly where each menu item is located on the screen but then again you need to put them there so that shouldn't be too hard. Since you will probably want to high-light the item when the cursor is over it and need to know where the magic key is pressed anyway you also must read the bios to obtain the cursor location on the screen. When both coincide and the key (that you have *instructed the user* to use to select an item - assume nothing!) is pressed invoke the code to run the selected item.
For what you want a column of text or pictures of function keys and what each function key does might be easiest. It doesn't matter where they are located on the screen and their use is nearly as old as computers. ASCII art is old stuff and well documented on the net. Now you just need to display (puts) the art or simple text and scan (looped getch) for a function key press or the Escape key (always provide an out). Something truly simple yet functional as this for example:
..... ..... ..... Press F10 to enjoy my superb bling Press F11 for Joe Blow's so-so bling Press F12 to exit this menu
But thats kinda old hat and a bit limiting and whats to stop the user from pressing return or whatever key and scrolling the stuff off the screen?
Since you need to take control of both the menu and the user why not switch to a graphics mode, paint some labeled buttons and use the mouse to select a menu item? The upshot is all user input is trapped and you place things on the screen in response to user input, rather than the other way around where you chase what the user may or may not put on the screen. Its way sexier and I think you will find it more intuitive to more people in this day and age. If you really want to get fancy you could do a set of up and down buttons to graphically show that the mouse is over the button and is about to be pressed. But all you really need do is place the text, track the mouse pointer location and loop a scan for a click over your button or text. If the click is over an item you placed on the screen switch the screen back to text mode and run the item's code or spawn it out to DOS. C source for mouse routines is widely available on the net. Hey, even I could post some 'read the bios' mouse source that I developed for my own use before the net was commonly available. But really, your C package should include some mouse and graphics routines.
John
.
- Next by Date: Re: Deleting files that contain certain text
- Next by thread: Re: Deleting files that contain certain text
- Index(es):
Relevant Pages
|