Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 30th, 2007, 6:00 PM   #1
Damienallen
Newbie
 
Join Date: Sep 2007
Posts: 3
Rep Power: 0 Damienallen is on a distinguished road
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.
Damienallen is offline   Reply With Quote
Old Sep 30th, 2007, 6:51 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Sep 30th, 2007, 11:44 PM   #3
ZenMasterJG
Hobbyist Programmer
 
ZenMasterJG's Avatar
 
Join Date: Nov 2004
Location: Boston, MA
Posts: 148
Rep Power: 4 ZenMasterJG is on a distinguished road
Send a message via AIM to ZenMasterJG
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.
ZenMasterJG is offline   Reply With Quote
Old Sep 30th, 2007, 11:50 PM   #4
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 245
Rep Power: 1 Jabo is on a distinguished road
I swear I think some of these teachers are just trying to see how much headache they can cause their students.
Jabo is offline   Reply With Quote
Old Sep 30th, 2007, 11:57 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Sep 30th, 2007, 11:59 PM   #6
MiKuS
Programmer
 
Join Date: Jun 2007
Posts: 93
Rep Power: 2 MiKuS is on a distinguished road
or maybe your teachers are just preparing you for the real world.
MiKuS is offline   Reply With Quote
Old Oct 1st, 2007, 12:10 AM   #7
ZenMasterJG
Hobbyist Programmer
 
ZenMasterJG's Avatar
 
Join Date: Nov 2004
Location: Boston, MA
Posts: 148
Rep Power: 4 ZenMasterJG is on a distinguished road
Send a message via AIM to ZenMasterJG
Quote:
Originally Posted by DaWei View Post
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.
Sure you can. IMHO curses makes life substantially easier, though.
ZenMasterJG is offline   Reply With Quote
Old Oct 1st, 2007, 2:37 AM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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);
}
wherex, wherey, clrscr, get a single char (no ENTER required) are all as simple, some just 2 lines of code.
__________________
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
DaWei is offline   Reply With Quote
Old Oct 1st, 2007, 3:00 AM   #9
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 927
Rep Power: 4 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by DaWei
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.
Actually, you might be surprised. Under Windows, at least, it should work as long as he stays away from SuperVGA modes. I've done programming with 'tweaked' VGA modes ('mode-x' and such) under Win2K, and it seems to work fine. My theory is that since the OS knows about the standard VGA registers, it can properly virtualize access. With the SVGA modes, the OS can't really regulate things, since each card behaves differently, so it just blocks access to the I/O ports involved (though there are hacks to get around this).
Quote:
Originally Posted by DaWei
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.
Yup. I believe this is exactly what the OP had in mind.

@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.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp
lectricpharaoh is offline   Reply With Quote
Old Oct 1st, 2007, 3:17 AM   #10
Damienallen
Newbie
 
Join Date: Sep 2007
Posts: 3
Rep Power: 0 Damienallen is on a distinguished road
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
Damienallen is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC