vc下找不到#include


如果頭文件有這個,#include <graphics.h>,編譯時會顯示
 Cannot open include file: 'graphics.h': No such file or directory

原因是graphics.h是Tc中專有的,<graphics.h>這個頭文件不是標准C的頭文件,vc下沒有這個頭文件,畫圖用控件來。還是有辦法在vc下用的,就是把這個頭文件和相關文件放在相應的lib和include目錄下,有人制作了一個軟件包, EasyX_2011驚蟄版http://www.easyx.cn,里面有頭文件和安裝方法,我只是把文件放在對應目錄的,找不到easyx的安裝文件,下了幾個都是沒有的,但是軟件說是有的,不知為什么,可能缺少安裝吧,運行還是一大堆錯誤。

 

網友文章:

VC 繪圖庫(下載graphics.h):可以在 VC 下像 Turbo C 的 BGI 一樣簡單的繪圖

 

為什么要寫這個庫? 
讓初學者從 Turbo C 2.0(以下簡稱 TC) 或 Borland C++ 3.1 開始學編程是個不錯的建議,只是 TC 的環境實在太老了,復制粘貼都很不方便。有一個 Win-TC,簡單用了一下,實在是個害人的東西,還不如 TC 好呢,因為它簡化了所有調試的部分(或許是我沒看到?),而調試是寫程序相當重要的一部分。 
不少老師直接拿 VC6 來講 C 語言的,因為 VC6 的編輯和調試環境都很優秀。只可惜在 VC6 下只能做一些文字性的練習題,想畫條直線畫個圓都很難,還要注冊窗口類、建消息循環等等,初學者會受嚴重打擊的。許多老師讓學生在 TC 下繪圖,因為這的確會讓人有興趣。 
所以,我想給初學者一個更好的學習環境,就是 VC6 的平台 + TC 的繪圖功能,於是就有了這個庫。如果您剛開始學 C 語言,或者您是一位教 C 語言的老師,那么這個東西一定會讓您興奮的。 
額外說明 
這個庫並不適合做產品,只建議用來入門學習。如果您想做簡單的繪圖產品,那么 SDL 庫或許更適合您。或者,直接介入 DirectX 編程吧。 
安裝 
下載的壓縮包里除了說明,只有兩個主要文件,將 graphics.lib 拷貝到 VC6 文件夾下的 Lib 文件夾內,將 graphics.h 拷貝到 Include 文件夾內,僅此而已,所以我就偷懶沒有做安裝程序了。 
使用說明 
目前只模擬了極少數 Borland C++ 3.1 的繪圖庫,只是把我個人理解中的初學者常用的圖形函數模擬了一下。 
使用上,基本和 TC 沒什么區別。看一個畫圓的例子吧: 
#include <graphics.h> // 就是需要引用這個圖形庫 
#include <conio.h> 
void main() 

initgraph(640, 480); // 這里和 TC 略有區別 
circle(200, 200, 100); // 畫圓,圓心(200, 200),半徑 100 
getch();              // 按任意鍵繼續 
closegraph();    // 關閉圖形界面 

呵呵,很簡單吧。

以下是這個庫所支持的函數列表。恩,僅僅是列表,詳細的使用說明在下載包內。 
void initgraph(int Width, int Height); // 初始化圖形環境 
void initgraph(int Width, int Height, int Flag); 
void closegraph(); // 關閉圖形環境 
void cleardevice(); // 清屏 
COLORREF getcolor(); // 獲取當前繪圖前景色 
void setcolor(COLORREF color); // 設置當前繪圖前景色 
COLORREF getbkcolor(); // 獲取當前繪圖背景色 
void setbkcolor(COLORREF color); // 設置當前繪圖背景色 
void getviewsettings(struct viewporttype *viewport); // 獲取視圖信息 
void setviewport(int left, int top, int right, int bottom, int clip); // 設置視圖 
void clearviewport(); // 清空視圖 
void getlinesettings(struct linesettingstype *lineinfo); // 獲取當前線形 
void setlinestyle(int linestyle, unsigned int upattern, int thickness); // 設置當前線形 
void getfillsettings(struct fillsettingstype *fillinfo); // 獲取填充類型 
void setfillstyle(int pattern, int color); // 設置填充類型 
void getfillpattern(char *pattern); // 獲取自定義填充類型 
void setfillpattern(const char *upattern, int color); // 設置自定義填充類型 
void getaspectratio(int *xasp, int *yasp); // 獲取當前縮放因子 
void setaspectratio(int xasp, int yasp); // 設置當前縮放因子 
void setwritemode(int mode); // 設置繪圖位操作模式 
void graphdefaults(); // 重置所有繪圖設置為默認值 
COLORREF getpixel(int x, int y); // 獲取點的顏色 
void putpixel(int x, int y, COLORREF color); // 畫點 
void moveto(int x, int y); // 移動當前點(絕對坐標) 
void moverel(int dx, int dy); // 移動當前點(相對坐標) 
void line(int x1, int y1, int x2, int y2); // 畫線 
void linerel(int dx, int dy); // 畫線(至相對坐標) 
void lineto(int x, int y); // 畫線(至絕對坐標) 
void rectangle(int left, int top, int right, int bottom); // 畫矩形 
void getarccoords(struct arccoordstype *arccoords); // 獲取圓弧坐標信息 
void arc(int x, int y, int stangle, int endangle, int radius); // 畫圓弧 
void circle(int x, int y, int radius); // 畫圓 
void pieslice(int x, int y, int stangle, int endangle, int radius); // 畫填充圓扇形 
void ellipse(int x, int y, int stangle, int endangle, int xradius, int yradius);// 畫橢圓弧線 
void fillellipse(int x, int y, int xradius, int yradius); // 畫填充橢圓 
void sector(int x, int y, int stangle, int endangle, int xradius, int yradius); // 畫填充橢圓扇形 
void bar(int left, int top, int right, int bottom); // 畫無邊框填充矩形 
void bar3d(int left, int top, int right, int bottom, int depth, int topflag); // 畫有邊框三維填充矩形 
void drawpoly(int numpoints, const int *polypoints); // 畫多邊形 
void fillpoly(int numpoints, const int *polypoints); // 畫填充的多邊形 
void floodfill(int x, int y, int border); // 填充區域 
void outtext(LPCTSTR textstring); // 在當前位置輸出文字 
void outtextxy(int x, int y, LPCTSTR textstring); // 在指定位置輸出文字 
int textwidth(LPCTSTR textstring); // 獲取字符串占用的像素寬 
int textheight(LPCTSTR textstring); // 獲取字符串占用的像素高 
void SetFont(int nHeight,int nWidth,int nEscapement,int nOrientation,int fnWeight,BYTE fdwItalic,BYTE fdwUnderline,BYTE fdwStrikeOut,LPCTSTR lpszFace); // 設置當前字體樣式 
void SetFont(const LOGFONT *font); // 設置當前字體樣式 
void GetFont(LOGFONT *font); // 獲取當前字體樣式 
void getimage(int left, int top, int right, int bottom, IMAGE *imgdst); // 從屏幕獲取圖像 
void getimage(const char *imagefile, IMAGE *imgdst); // 從 BMP 文件獲取圖像 
void getimage(const IMAGE *imgsrc, int left, int top, int right, int bottom, IMAGE *imgdst); // 從 IMAGE 對象獲取圖像 
void putimage(int left, int top, IMAGE *img, int op); // 繪制圖像 
int getmaxcolor(); // 獲取最大顏色值 
int getmaxx(); // 獲取最大 x 坐標 
int getmaxy(); // 獲取最大 y 坐標 
int getx(); // 獲取當前 x 坐標 
int gety(); // 獲取當前 y 坐標 
int GetVer(); // 獲取當前版本

http://student.csdn.net/link.php?url=http://hi.baidu.com%2Fyangw80%2Fblog%2Fitem%2F63ff598072a9f9d09023d97f.html

http://student.csdn.net/space.php?uid=52781&do=blog&id=4228

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM