Why Is My Turbo C Graphics Window Not Displaying Correctly?

  • Thread starter Thread starter Yamna
  • Start date Start date
  • Tags Tags
    Window
AI Thread Summary
The discussion centers around issues with a graphics program written in C that fails to create a window as expected. The program compiles without errors, but the graphical output does not appear. Participants note that the program is being run in Turbo C on Windows XP, which may affect its functionality. It is highlighted that the program attempts to create a window using old DOS methods, which may not be compatible with modern Windows environments. Suggestions include using a DOS emulator or Virtual PC to run the program in a more compatible setting, as the graphics functions may not work properly in the Windows console. The conversation emphasizes the limitations of running legacy DOS applications in contemporary operating systems.
Yamna
Messages
4
Reaction score
0
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 anyone tell me why?and how can i eject this error.
mind that compiler is running the program correctly..
C Syntax (Toggle Plain Text)
#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();
}:confused:
 
Technology news on Phys.org
How are you running Turbo C, in MSDOS or a virtual PC running MSDOS? Is Turbo C running ok in it's text windowed mode?
 
yes its working properly i am using windows xp.but does that matter?:confused:
 
Yamna said:
according to me a window should be created

You are not trying to create a window (as a window in Microsoft Windows), but to steal a whole screen. Such an approach worked correctly in the old DOS times, but it doesn't work under Windows - unless you will use some kind of DOS emulator.
 
Yamna said:
yes its working properly i am using windows xp.but does that matter?
I'll assume you're doing this in full screen mode (as opposed to windowed mode)? Even so, I'm not sure if all the EGA/VGA bios calls (INT 10H) are emulated in the dos console window for Windows XP. For example, with Windows XP dos console in full screen mode, my old msdos programs are able to load fonts via bios calls, but I'm not able to change the number of lines between 25, 43, or 50 via bios calls.

You could consider using Virtual PC 2007 and installing MSDOS onto it, if you have a copy of MSDOS that you can install. It's a bit of a pain to transfer stuff over to virtual PC. I trasfer files to a cd-rw disc, then copy them from the cd-rw dics in Virtual PC. I haven't tried going the other way. There may be utilities that can transfer to/from a virtual hard drive image, but I haven't tried to look for these.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Back
Top