Problem with window in turbo c

  • Thread starter Yamna
  • Start date
  • Tags
    Window
In summary, the conversation discusses the use of a program on Windows XP that is designed to create a window, but is not functioning properly. It is suggested that the issue may be due to using the program in full screen mode and the limitations of the EGA/VGA bios calls in the DOS console window on Windows XP. It is also suggested to try using Virtual PC 2007 and installing MSDOS onto it to potentially resolve the issue.
  • #1
Yamna
4
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
  • #2
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?
 
  • #3
yes its working properly i am using windows xp.but does that matter?:confused:
 
  • #4
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.
 
  • #5
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.
 

1. Why is my window not appearing in Turbo C?

There could be several reasons for this problem. One possibility is that you have accidentally closed the window or minimized it. Another possibility is that there is a coding error in your program that is preventing the window from being displayed. It is also possible that there is an issue with your computer's graphics driver.

2. How can I fix the problem with my window in Turbo C?

The first step to fixing this problem is to check if the window is closed or minimized. If it is, simply restore it by clicking on the icon in the taskbar. If the window is not appearing due to a coding error, review your code carefully and debug any errors. You may also need to update your graphics driver to ensure it is compatible with Turbo C.

3. My window appears distorted in Turbo C. How can I fix this?

This issue is most likely caused by a problem with your graphics driver. Try updating the driver to the latest version or reinstalling it. You can also check the resolution settings in Turbo C and make sure they are compatible with your computer's screen resolution. Additionally, some third-party antivirus or firewall programs may interfere with Turbo C and cause distortion in the window. Try disabling these programs and see if the issue persists.

4. Why is my window freezing or crashing in Turbo C?

This problem could be due to a memory issue, where Turbo C is using up too much memory and causing the window to freeze or crash. Make sure to save your work frequently and close any unnecessary programs while using Turbo C. You can also try increasing the memory allocated to Turbo C in its settings. If the issue persists, it could be due to a compatibility issue with your computer's operating system.

5. How can I prevent my window from disappearing when I run my program in Turbo C?

This issue is most likely caused by the "system" command in your code, which clears the screen before running the program. To prevent the window from disappearing, you can either remove the "system" command or add a "getch" command at the end of your code to keep the window open until you press a key. You can also run the program in "Debug" mode, which will keep the window open after the program finishes running.

Similar threads

  • Programming and Computer Science
Replies
1
Views
769
Replies
1
Views
1K
  • Programming and Computer Science
2
Replies
35
Views
2K
  • Introductory Physics Homework Help
Replies
25
Views
461
Replies
3
Views
318
  • Introductory Physics Homework Help
Replies
7
Views
674
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
12
Views
1K
Replies
50
Views
3K
  • Calculus and Beyond Homework Help
Replies
16
Views
1K
Back
Top