Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GUI for DOS 3

Status
Not open for further replies.

Elena

Technical User
Oct 20, 2000
112
0
0
US
Hi,

I want to make a simple front end user interface for DOS that will run other programs based on the menu selections. Just a few menus that the use can select with a mouse or keyboard. However, I am new to C and I don't know where to start.

Can someone point me in the right direction?

Thanks,

Elena
 
Well it seems to me a simple prompt/reply approach will work
Code:
int main ( ) {
  int choice;
  printf( "1. Work\n" );
  printf( "2. Play\n" );
  scanf( "%d", &choice );
  if ( choice == 1 ) {
    // print some work related entries
  } else
  if ( choice == 2 ) {
    // print some play related entries
  }
}

When you get to the end of a menu sequence, then use something like
Code:
system("game.exe");

--
 
20 years ago we used some quasi-GUI (or direct console) DOS libraries (sometimes with full windows capabilities, mouse interface etc). Alas, I forget its names now...

10 years ago I wrote an application for DOS with Borland Turbo C BGI library (mouse interface via BIOS calls) for the very old target PC. Where is that PC now?..

Better try use a classic simple (and more or less portable;) text console approach, something of the Salem's post sort...
 
If you want to spend a little bit of money on this, check out


We used this many years ago, I still have a copy of it. For DOS it worked great and was easy to use.

I did develop something similar on my own way back when (without mouse support). If interested (and if I can find it), I'd be willing to post the source somewhere for download. It wasn't very elegant since it was one of the first things I ever did in C, but it did the job.

Good luck.
 
There are no readily available functions for using the mouse in the C standard libraries. Butit is not to difficult to incorporate some assembly into your programs specifically for dealing with the mouse. Take a look at the code I wrote...
Code:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

#define NOT_INSTALLED   2
#define TWO_BUTTON      3
#define NOT_TWO_BUTTON  4
#define OTHER           5
#define SHOW            2
#define LB_PRESS        1

int   InitMouse   (void);
void  ShowMouse   (int);
void  ExitProg    (int);
int   GetStatus   (unsigned int &, unsigned int &);


void main (void)
{
  int status;
  unsigned int x, y;

  clrscr();
  status = InitMouse ();
  if (status == NOT_INSTALLED)
    ExitProg (1);
  ShowMouse (SHOW);
  printf ("Push left button to end...\n");
  while (GetStatus (x, y) != LB_PRESS)
  {
    gotoxy(10, 10);
    printf("x = %3d, y = %3d", x, y);
  }
  gotoxy(1, 12);
  printf ("Left button pushed !\n");
  ExitProg (0);
}


int InitMouse (void)
{
  asm {
    mov ax,0021h
    int 33h
  }
  if (_AX != 0xffff)
  {
    // 0xffff => mouse driver installed
    printf ("Mouse driver not installed!\n");
    return NOT_INSTALLED;
  }
  else if (_BX == 0xffff)
  {
    // 0xffff => 2 button mouse
    printf ("Normal mouse with 2 buttons installed.\n");
    return TWO_BUTTON;
  }
  else if (_BX == 0x0000)
  {
    printf ("Mouse with more/less than 2 buttons installed.\n");
    return NOT_TWO_BUTTON;
  }
  printf ("Non standard mouse installed.\n");
  return OTHER;
}


void ShowMouse (int show)
{
  if (show == SHOW)
    asm mov ax,0001h // show mouse
  else
    asm mov ax,0002h // hide mouse
  asm int 33h
}


int GetStatus (unsigned int &xpos, unsigned int &ypos)
{
  asm {
    mov ax,0003h
    int 33h
  }
  xpos = _CX;
  ypos = _DX;
  if (_BX & 0x0001) // '0' bit indicates LB status
    return LB_PRESS;
  else
    return 0;
}


void ExitProg (int retval)
{
  printf ("Press a key to return to system\n");
  getch ();
  exit (retval);
}
Sorry for not commenting to much, but everything should be straightforeward. Hope thats a help.
:)

Don't hate the player - hate the game
 
Thank you all for your posts. These are all helpful. As for now, since I have little time left, I will use the basic prompt/reply approach. But I have to learn how to use menus as I expand my program. I have to get phase 1 done by tomorrow.

itgsd,
Since I am still trying to learn this on my own, I would appreciate it if you could post your source, so I can see how it works.

adholioshake,
Very nice, thank you!!



Again, thanks to all.

Elena
 
> I would appreciate it if you could post your source, so I can see how it works.

I'll dig through the archives tonight and try to find it.

Good luck.
 
itsgsd,

Thank you!

Elena
 
I found the source code. I've posted it at:


Some of the functions may be specific to the Borland compilers, but I believe I saw somewhere that you were using Turbo C++.

As I said, I wrote this a long time ago so it isn't very elegant nor super readable.

Hope it helps.

Good Luck.
 
itsgsd,

Thank you for taking the time to find that for me. I really appreciate your efforts!

Best regards,

Elena
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top