this is my program but this is not working well.according to me a window should be created and some text will be written there.but the window is not working please can any one tell me why?and how can i eject this error.
mind that compiler is running the program correctly..

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int left, top, right, bottom;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "c:\\tc\\bgi");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   left = getmaxx() -getmaxx()+1;
   top = getmaxy()-getmaxy()+1;
   right = getmaxx();
   bottom = getmaxy()-getmaxy()+20;
      /* draw a rectangle */
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"file name");

   right=getmaxx()/5;
   top=bottom;
   bottom=bottom+20;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"new");

   left=right;
   right=(getmaxx()/5)*2;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"open");

   left=right;
   right=(getmaxx()/5)*3;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"save");

   left=right;
   right=(getmaxx()/5)*4;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"save as");

    left=right;
   right=getmaxx();
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"delete");

   left=1;
   right=getmaxx()/7;
   top=bottom;
   bottom=bottom+20;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"cut");

   left=right;
   right=(getmaxx()/7)*2;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"copy");

   left=right;
   right=(getmaxx()/7)*3;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"paste");

   left=right;
   right=(getmaxx()/7)*4;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"t_colour");

   left=right;
   right=(getmaxx()/7)*5;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"text_size");

   left=right;
   right=(getmaxx()/7)*6;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"text_type");

   left=right;
   right=getmaxx();
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"bk_colour");

   left=1;
   right=(getmaxx()/8);
   top=bottom;
   bottom=bottom+20;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"bold");

   left=right;
   right=(getmaxx()/8)*2;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"italic");

   left=right;
   right=(getmaxx()/8)*3;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"underline");

   left=right;
   right=(getmaxx()/8)*4;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"right");

   left=right;
   right=(getmaxx()/8)*5;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"left");

   left=right;
   right=(getmaxx()/8)*6;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"mid");

   left=right;
   right=(getmaxx()/8)*7;
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"justified");

   left=right;
   right=getmaxx();
   rectangle(left,top,right,bottom);
   outtextxy(left+2,top+10,"highlighter");

   left=1;
   right=getmaxx();
   top=bottom;
   bottom=getmaxy();

   window(left,top,right,bottom);
   cputs("hello world in window");

   getch();
   /* clean up */
   closegraph();
   return 0;
   getch();
}

Recommended Answers

graphics.h was a library in the 16 bit world where it is used for doing graphics in DOS with Borland C++ 3.x
(In short it is an old & unsupported library nowadays )

...maybe that's where your problem starts

try using

Jump to Post

thanks for your response but i have to work with all these stupid and old things that is what my assignment needs. graphics.h and the window function is working properly in all other programs and other functions but is doing problem in given piece of code.:S

Sad to say that's …

Jump to Post

All 5 Replies

hey why is there a -1 vote??????:?::@:yawn::@

:angry:
please tell me the answer of my question instead of voting stupidly and if you are voting me in negative please tell me the reason too.

graphics.h was a library in the 16 bit world where it is used for doing graphics in DOS with Borland C++ 3.x
(In short it is an old & unsupported library nowadays )

...maybe that's where your problem starts

try using Forger's for making a window

graphics.h was a library in the 16 bit world where it is used for doing graphics in DOS with Borland C++ 3.x
(In short it is an old & unsupported library nowadays )

...maybe that's where your problem starts

try using Forger's for making a window

thanks for your response but i have to work with all these stupid and old things that is what my assignment needs. graphics.h and the window function is working properly in all other programs and other functions but is doing problem in given piece of code.:S

thanks for your response but i have to work with all these stupid and old things that is what my assignment needs. graphics.h and the window function is working properly in all other programs and other functions but is doing problem in given piece of code.:S

Sad to say that's as much help as I can give
I have no experience using that library and my IDE can't use graphics.h anymore so I can't give a better response
try to compare this code with your other programs and carefully check each details or maybe hope that veteran users might give a response to this thread

good luck :cool:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.