![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2007
Posts: 3
Rep Power: 0
![]() |
Dos based Gui
For an assignment I have to create a simple dos based database app. I want to improve on my work though by creating a simple GUI similar to EDIT under dos. It looks like a simple textmode interface that hopefully isn't too difficult to do. Please can someone point me in the right direction.
P.S. I don't really want to use any external libraries. I believe I may be able to use graphics.h from the old Borland compiler, however I'm not sure where to start. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
It's unlikely that you'll be able to use the old Borland stuff. If you're talking about the vintage I'm thinking of, it won't run under a memory-managed, I/O protected system.
I might add that neither the old EDIT that ran under MS-DOS nor the EDIT that runs under cmd.exe is a GUI. They're purely text mode. You can achieve that functionality by merely making a console-based application.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
You could use conio.h, though thats a pretty crufty old library.
The easiest way to do what you're talking about, though, is through something like curses, though you'll have to get over not using external libraries. PDCurses is your best bet (http://pdcurses.sourceforge.net/) though, be forewarned, curses and Windows aren't happy together. PDCurses, i think, has a better chance of working then any of the other "curses for windows" libraries I've seen, but thats only because I've never heard of any of those other libraries working at all. Good luck. |
|
|
|
|
|
#4 |
|
Not a user?
Join Date: Sep 2007
Posts: 272
Rep Power: 2
![]() |
I swear I think some of these teachers are just trying to see how much headache they can cause their students.
|
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
You don't need curses for Windows. You can just use the console API. Writing the things that used to be in conio.h (Dev-Cpp still has a conio.h) is almost trivial.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Jun 2007
Posts: 134
Rep Power: 2
![]() |
or maybe your teachers are just preparing you for the real world.
|
|
|
|
|
|
#7 |
|
Hobbyist Programmer
|
|
|
|
|
|
|
#8 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Could just be me, but I don't see anything particularly difficult about this, and all one needs is windows.h.
{
....
HANDLE consoleIn;
HANDLE consoleOut;
CONSOLE_SCREEN_BUFFER_INFO screenInfo;
consoleIn = GetStdHandle (STD_INPUT_HANDLE);
consoleOut = GetStdHandle (STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo (consoleOut, &screenInfo);
gotoxy (4, 12);
....
}
void gotoxy (int x, int y)
{
COORD here;
here.X = x;
here.Y = y;
SetConsoleCursorPosition (consoleOut, here);
}
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#9 | ||
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,034
Rep Power: 5
![]() |
Quote:
Quote:
@OP: if you want to do this sort of thing, you need to be clear whether you're writing a true DOS program, or simply working in a command window in WinNT/2K or later. Under Win9x/ME, it was a 'DOS box', but under later versions, it's not. If you're writing a DOS program, you can use several methods. One is to call the BIOS (generally done through assembly, inline or otherwise, or the interrupt wrapper functions available in many DOS compilers). This is one of the slower methods in most cases, not that you'll notice on modern machines. Another is direct memory access; text mode video memory is at a fixed (for the video mode) address. This memory is alternating character and attribute bytes; the character is obviously the extended ASCII code of the character at that position in the frame buffer, and the attribute byte is a bit field representing foreground and background (3 bits each), intensity (one bit; essentially it adds to the foreground field), and the blink/background intensity bit (it either makes the foreground text blink, or expands the range of background colors much as the intensity bit does for foreground colors). I don't recall offhand whether it's the attribute or character byte that comes first, though. Note that this method only affects the content of the frame buffer. It does not reposition the cursor, and you need to address this issue, which can be done by calling BIOS to set the cursor position, or directly accessing the video card registers (typically through assembly, though some DOS compilers support wrapper functions to read and write I/O ports). Another is to use features supplied by your compiler. Some DOS compilers have library functions to position the text-mode cursor; subsequent text writes (via printf(), for example) will take place at this new position. Likewise, you might find functions to set the text color, etc. Lastly, you can use the functionality of a console driver that provides positioning and attribute control. An example would be DOS's ANSI.SYS, but you can get better ANSI drivers, such as NNANSI. In this case, you just embed escape sequences into your text output, and you're set. This solution isn't exactly the best, though; ANSI drivers aren't commonly set up on Windows machines these days. Also, the text can get cluttered up with escape sequences, which can make for ugly string literals (though this isn't so much a drawback as something you need to keep in mind). You can write wrapper functions to bypass this last issue. If you're writing a Windows console program, you can use the Win32 API to handle this, or you can- oh wait, the Win32 API is the only way. If this is what you're doing, I can give you some pointers, but if it's not, I'm not going to bother.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
||
|
|
|
|
|
#10 |
|
Newbie
Join Date: Sep 2007
Posts: 3
Rep Power: 0
![]() |
thanks lectricpharaoh you read me correct, sorry for my poor use of terminology. It's a dos console app i'm doing but it must run under winNT style systems in a command window. The compiler i'm using is minGW through DevCPP IDE. This looks like its more hassle than it is worth, I may just go for a solid pass rather than mess things up wholesale.
Thanks for the help guys |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Which GUI toolkit is best for me? | inhahe | Python | 7 | Dec 9th, 2007 9:34 AM |
| question regarding GUI factory. | rwm | C++ | 3 | Aug 17th, 2007 8:58 AM |
| Which is easier for making a GUI program? | 357mag | Java | 6 | Jul 29th, 2007 5:08 PM |
| C++ IDEs/Java Libraries/Making a Text Based Game! | Tsar_of_Cows | Java | 17 | Jun 22nd, 2007 1:52 PM |
| Web based version? | bja888 | Existing Project Development | 7 | Oct 31st, 2005 9:00 PM |