请问怎样对Turbo c++图形编辑做设置

geniusbamboo 2003-08-20 08:14:27

我从某处找到这个,但是maybe我的是Turbo c++3.1所以问题还是无法解决。很急啊,拜托高手指点。也请耐心看完!^_^

Turbo C对于用initgraph()函数直接进行的图形初始化程序, 在编译和链接时并没有将相应的驱动程序(*.BGI)装入到执行程序, 当程序进行到intitgraph()语句时, 再从该函数中第三个形式参数char *path中所规定的路径中去找相应的驱动程序。若没有驱动程序, 则在C:\TC中去找, 如C:\TC中仍没有或TC不存在,
将会出现错误:
BGI Error: Graphics not initialized (use'initgraph')
因此, 为了使用方便, 应该建立一个不需要驱动程序就能独立运行的可执行
图形程序,Turbo C中规定用下述步骤(这里以EGA、VGA显示器为例):
1. 在C:\TC子目录下输入命令:BGIOBJ EGAVGA
此命令将驱动程序EGAVGA.BGI转换成EGAVGA.OBJ的目标文件。
2. 在C:\TC子目录下输入命令:TLIB LIB\GRAPHICS.LIB+EGAVGA
此命令的意思是将EGAVGA.OBJ的目标模块装到GRAPHICS.LIB库文件中。
3. 在程序中initgraph()函数调用之前加上一句:
registerbgidriver(EGAVGA_driver):
该函数告诉连接程序在连接时把EGAVGA的驱动程序装入到用户的执行程序中。
经过上面处理,编译链接后的执行程序可在任何目录或其它兼容机上运行。
...全文
38 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
柯本 2003-08-20
  • 打赏
  • 举报
回复
我在BC++2.0上试了没问题程序用examples
记得以前在C/C++版有过同样问题
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

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

/* register a driver that was added into graphics.lib */
errorcode = registerbgidriver(EGAVGA_driver);

/* report any registration errors */
if (errorcode < 0)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

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

/* draw a line */
line(0, 0, getmaxx(), getmaxy());

/* clean up */
getch();
closegraph();
return 0;
}
把你的程序贴出来看看
柯本 2003-08-20
  • 打赏
  • 举报
回复
很久前(N年了)作过,应该没问题,不过如果你用到字体,也要用同样方法将它加入LIB

552

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 茶馆
社区管理员
  • 茶馆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧