Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DOS graphics in Windows;how?

7 views
Skip to first unread message

scooper

unread,
Apr 16, 2009, 9:26:02 PM4/16/09
to
I have a graphics program writen in DOS Borland C++ and would like to
translate into Turbo C++.
What changes do I need to make to this program?
Thanks to all,
scooper.

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

int main(void)
{
/* select a driver and mode that supports */
/* multiple drawing colors. */
int gdriver = EGA, gmode = EGAHI, errorcode;
int color, maxcolor, x, y;
char msg[80];

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* 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 */
}

/* maximum color index supported */
maxcolor = getmaxcolor();

/* for centering text messages */
settextjustify(CENTER_TEXT, CENTER_TEXT);
x = getmaxx() / 2;
y = getmaxy() / 2;

/* loop through the available colors */
for (color=1; color<=maxcolor; color++)
{
/* clear the screen */
cleardevice();

/* select a new background color */
setcolor(color);

/* output a messsage */
sprintf(msg, "Color: %d", color);
outtextxy(x, y, msg);
getch();
}

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


paralysis

unread,
Apr 16, 2009, 10:33:45 PM4/16/09
to
Hi scooper,
First of all, I would recommend posting to a Microsoft or Windows
specific newsgroup. You'll probably get more help there. This
newsgroup is mostly geared toward the C++ standard, and not really
OS-, compiler-, or architecture- specific questions. I think there
would be more people in the microsoft.public.vc.* newsgroups that
could help you.
Don't want you to leave empty handed, though. Maybe check MSDN for
the GDI Reference. It's been years since I programmed on Windows, but
I think if you look up the WM_PAINT event, and the BeginPaint function
(and relatives), then you'll be on the right track.
Regards
--Jonathan

Andy Champ

unread,
Apr 18, 2009, 4:17:46 PM4/18/09
to
scooper wrote:
> I have a graphics program writen in DOS Borland C++ and would like to
> translate into Turbo C++.
> What changes do I need to make to this program?

You need a Windoze version of your graphics library. Then you need to
rewrite the app. to fit it.

That program would work fine under Windows - given the right library.
I'd suggest you look for a Borland specific newsgroup - there are lots
of them, I have no idea how active they are. Someone may know of such a
library.

As has been said, this isn't the right place.

Andy

0 new messages