int86 0x33 (mouse) Borland C++ 3.0 Console app

Borland C++ 3.0 allows me to create a console application (exe) with the Console Wizard(new project).  In the help of the compiler I find documentation of the int86 routine (normally found in dos.h).  (Unfortunaly no int86 in dos.h)

I try to run all my old dos examples (mouse driven) with Borland C++ 3.0.

Because int86 doesn't work.  I tried to place directly
asm mov ax,...; asm int 33h; in the C++ code, but my
assemble knowledge is poor.   I even tried the smallest possible mouse int 33h (just initialize the mouse), but the program crashes.

I am looking for an easy way to check the mouse position, state of the buttons,... in the old way.  Perhaps it is no longer possible. (Nevertheless it is still documented in the help file).

If I want to run the old dos programs under windows I have to simulate all: getch, kbhit, cin, cout, delay (not easy).
I am working on this possibility, but this is an hard way (I have to use a separated thread ).  I still hope that someone will be able to help me to check the mouse position, mouse buttons in the old way (int86) with Borland C++ Builder.  

(Also C++ Builder 1.0 has the same problem).

I include here the code of a small example under dos in the hope that someone will be able to run it under Borland C++ 3.0.

///////////good luck
#include <stdio.h>
#include <conio.h>
#include <iostream.h>

// Mouse.h
#include <dos.h>

#if !defined MOUSE_H
#define MOUSE_H

class Mouse
{static union REGS r;
static int aantalknoppen;
// status van een Mouse-object
static int status;

{setbuf(stdout,NULL);  // nodig voor DJGPP compiler (geen schermbuffering)
 // cout is met stdout verbonden
// status=0; = 0;        int86(0x33,&r,&r);
 status =;   aantalknoppen = r.x.bx;
int allgood(){return status=-1 || status== 65535;}
void show(){ = 1; int86(0x33,&r,&r); }
void hide()  { = 2; int86(0x33,&r,&r); }

void changeposition(int xm,int ym )
  { = 4; = xm; r.x.dx = ym; int86(0x33,&r,&r);  }

void position(int &xm,int &ym)
{ if(!allgood()){xm=0;ym=0;return;}
  xm=ym=1; = 3;     int86(0x33,&r,&r);   xm =;ym= r.x.dx ;

void textposition(int &xm,int &ym){ position(xm,ym);
                                 xm++;ym++;// nodig omdat Mouse anders linker

void setArea( int minX, int maxX, int minY, int maxY )
  { = 7; = minX;r.x.dx = maxX;   int86( 0x33, &r, &r ); = 8; = minY; r.x.dx = maxY;  int86( 0x33, &r, &r );

int pressed( int knop=1/*left*/ )
  { = 5;  r.x.bx = knop; int86(0x33,&r,&r);
      return & knop;  }

int released( int knop=1/*left*/ )
  { = 6;    r.x.bx = knop;   int86( 0x33, &r, &r );
      return & knop;  }

int left()       { return pressed( 1 ); }
//int midden()    { return pressed( 4 ); }
int right()      { return pressed( 2 ); }
int leftreleased()    { return released( 1 ); }
//int middenreleased() { return released( 4 ); }
int rightreleased()   { return released( 2 ); }
int Mouse::status=0;
union REGS Mouse::r;
int Mouse::aantalknoppen;


#include <iostream.h>                   // nodig voor cout
#include <conio.h>                      // nodig voor clrscr,gotoxy,...
#include   <dos.h>

#include <iostream.h>                   // nodig voor cout
#include <conio.h>                      // nodig voor clrscr,gotoxy,...
#include   <dos.h>

class clock
{ struct  time t;
  int x, y;
  int hour, minute, second;
clock(int xx,int yy){x = xx; y = yy;}
void show()
   if ( (int)t.ti_hour != hour || (int)t.ti_min != minute
                        || (int)t.ti_sec != second)
      {  gotoxy(x, y);
       cout<< (int)t.ti_hour<<":"  << (int)t.ti_min<<":"
           << (int)t.ti_sec<<"    ";
       hour= (int)t.ti_hour; minute = (int)t.ti_min ;
       second = (int)t.ti_sec;

 { Mouse m;
   clock kl(1,1);
   clock kl2(40,25);
   char letter;   int oldx, oldy, x, y;
   letter =' ';;   clrscr();
   while( letter != 'x' )
      if (m.left() )
       { // left clicked
         m.textposition(oldx, oldy);
          gotoxy(oldx, oldy); cout<<"L";
         while (m.left() )
              {m.textposition(x, y);
               if ( oldx != x || oldy != y )
                   { // left pressed en moving
                     gotoxy(x, y);   cout<<"*"; }
               oldx = x; oldy  = y;
         // left released
         gotoxy(oldx ,oldy);cout<<"released";
      if (m.right() )
       { // right clicked
         m.textposition(oldx, oldy);
          gotoxy(oldx, oldy); cout<<"R";
         while (m.right() )
              {m.textposition(x, y);
               if ( oldx != x || oldy != y )
                   { // right pressed en moving
                     gotoxy(x, y);   cout<<"."; }
               oldx = x; oldy = y;
         // right released
         gotoxy(oldx ,oldy);cout<<"right";
      if (kbhit() ) {letter =getch();
                 cout<<letter;    }
   return 0;
Who is Participating?
nietodConnect With a Mentor Commented:
A win32 console application (like you are writting) is a 32 bit window program, it is not a DOS program.  You cannot call the 16 bit DOS interrupts from a 32 bit application.  Thus this whole approach is out.  But there is hope.  details follow.
You can use the window API functions to access the mouse.  I'll list the functions that will be of most value to you.  Why don't you then read up on them in the windows documentation and if you have questions you can ask me about them.  Then we can discuss actually changing your code to use them (there will be one difficulty).

Use GetCursorPos() to get the current mouse position (for position()).
Use the SetCursorPos() to move the mouse (for changeposition()).
Use GetKeyState() with keys of VK_LBUTTON, VK_MBUTTON, and VK_RBUTTON to get the state of the mouse buttons.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.