📄 fg.htm
字号:
bytes per sector %5d\n", <br>
diskinfo.fi_bysec); <br>
} </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: getfillpattern <br>
功 能: 将用户定义的填充模式拷贝到内存中 <br>
用 法: void far getfillpattern(char far *upattern); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int maxx, maxy; <br>
char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x25,
0x27, 0x04, 0x04}; </p>
<p> /* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error occurred */
<br>
{ <br>
printf("Graphics error:
%s\n", grapherrormsg(errorcode)); <br>
printf("Press any key to
halt:"); <br>
getch(); <br>
exit(1); /* terminate with an
error code */ <br>
} </p>
<p> maxx = getmaxx(); <br>
maxy = getmaxy(); <br>
setcolor(getmaxcolor()); </p>
<p> /* select a user defined fill pattern */ <br>
setfillpattern(pattern, getmaxcolor()); </p>
<p> /* fill the screen with the pattern */ <br>
bar(0, 0, maxx, maxy); </p>
<p> getch(); </p>
<p> /* get the current user defined fill pattern */ <br>
getfillpattern(pattern); </p>
<p> /* alter the pattern we grabbed */ <br>
pattern[4] -= 1; <br>
pattern[5] -= 3; <br>
pattern[6] += 3; <br>
pattern[7] -= 4; </p>
<p> /* select our new pattern */ <br>
setfillpattern(pattern, getmaxcolor()); </p>
<p> /* fill the screen with the new pattern */ <br>
bar(0, 0, maxx, maxy); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: getfillsettings <br>
功 能:
取得有关当前填充模式和填充颜色的信息 <br>
用 法: void far getfillsettings(struct fillsettingstype
far *fillinfo); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>/ the names of the fill styles supported */ <br>
char *fname[] = { "EMPTY_FILL", <br>
"SOLID_FILL", <br>
"LINE_FILL", <br>
"LTSLASH_FILL", <br>
"SLASH_FILL", <br>
"BKSLASH_FILL", <br>
"LTBKSLASH_FILL", <br>
"HATCH_FILL", <br>
"XHATCH_FILL", <br>
"INTERLEAVE_FILL", <br>
"WIDE_DOT_FILL", <br>
"CLOSE_DOT_FILL", <br>
"USER_FILL" <br>
}; </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
struct fillsettingstype fillinfo; <br>
int midx, midy; <br>
char patstr[40], colstr[40]; </p>
<p> /* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) /* an error occurred */
<br>
{ <br>
printf("Graphics error:
%s\n", grapherrormsg(errorcode)); <br>
printf("Press any key to
halt:"); <br>
getch(); <br>
exit(1); /* terminate with an
error code */ <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<p> /* get information about current fill pattern and
color */ <br>
getfillsettings(&fillinfo); </p>
<p> /* convert fill information into strings */ <br>
sprintf(patstr, "%s is the fill style.",
fname[fillinfo.pattern]); <br>
sprintf(colstr, "%d is the fill color.",
fillinfo.color); </p>
<p> /* display the information */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); <br>
outtextxy(midx, midy, patstr); <br>
outtextxy(midx, midy+2*textheight("W"),
colstr); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: getftime <br>
功 能: 取文件日期和时间 <br>
用 法: int getftime(int handle, struct ftime *ftimep); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <io.h> </p>
<p>int main(void) <br>
{ <br>
FILE *stream; <br>
struct ftime ft; </p>
<p> if ((stream = fopen("TEST.$$$", <br>
"wt")) ==
NULL) <br>
{ <br>
fprintf(stderr, <br>
"Cannot open output file.\n"); <br>
return 1; <br>
} <br>
getftime(fileno(stream), &ft); <br>
printf("File time: %u:%u:%u\n", <br>
ft.ft_hour, ft.ft_min, <br>
ft.ft_tsec
* 2); <br>
printf("File date: %u/%u/%u\n", <br>
ft.ft_month, ft.ft_day, <br>
ft.ft_year+1980); <br>
fclose(stream); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: getgraphmode <br>
功 能: 返回当前图形模式 <br>
用 法: int far getgraphmode(void); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int midx, midy, mode; <br>
char numname[80], modename[80]; </p>
<p>/* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<p>/* read result of initialization */ <br>
errorcode = graphresult(); <br>
/* an error occurred */ <br>
if (errorcode != grOk) <br>
{ <br>
printf("Graphics error:
%s\n", <br>
grapherrormsg(errorcode)); <br>
printf("Press any key to
halt:"); <br>
getch(); <br>
/* terminate with an error code */ <br>
exit(1); <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<p>/* get mode number and name strings */ <br>
mode = getgraphmode(); <br>
sprintf(numname, <br>
"%d is the current mode number.", <br>
mode); <br>
sprintf(modename, <br>
"%s is the current graphics mode", <br>
getmodename(mode)); </p>
<p>/* display the information */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); <br>
outtextxy(midx, midy, numname); <br>
outtextxy(midx, midy+2*textheight("W"), <br>
modename); </p>
<p>/* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: getftime <br>
功 能: 取文件日期和时间 <br>
用 法: int getftime(int handle, struct ftime *ftimep); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <io.h> </p>
<p>int main(void) <br>
{ <br>
FILE *stream; <br>
struct ftime ft; </p>
<p> if ((stream = fopen("TEST.$$$", <br>
"wt")) ==
NULL) <br>
{ <br>
fprintf(stderr, <br>
"Cannot open output file.\n"); <br>
return 1; <br>
} <br>
getftime(fileno(stream), &ft); <br>
printf("File time: %u:%u:%u\n", <br>
ft.ft_hour, ft.ft_min, <br>
ft.ft_tsec
* 2); <br>
printf("File date: %u/%u/%u\n", <br>
ft.ft_month, ft.ft_day, <br>
ft.ft_year+1980); <br>
fclose(stream); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: getgraphmode <br>
功 能: 返回当前图形模式 <br>
用 法: int far getgraphmode(void); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int midx, midy, mode; <br>
char numname[80], modename[80]; </p>
<p>/* initialize graphics and local variables */ <br>
initgraph(&gdriver, &gmode, ""); </p>
<p>/* read result of initialization */ <br>
errorcode = graphresult(); <br>
/* an error occurred */ <br>
if (errorcode != grOk) <br>
{ <br>
printf("Graphics error:
%s\n", <br>
grapherrormsg(errorcode)); <br>
printf("Press any key to
halt:"); <br>
getch(); <br>
/* terminate with an error code */ <br>
exit(1); <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; </p>
<p>/* get mode number and name strings */ <br>
mode = getgraphmode(); <br>
sprintf(numname, <br>
"%d is the current mode number.", <br>
mode); <br>
sprintf(modename, <br>
"%s is the current graphics mode", <br>
getmodename(mode)); </p>
<p>/* display the information */ <br>
settextjustify(CENTER_TEXT, CENTER_TEXT); <br>
outtextxy(midx, midy, numname); <br>
outtextxy(midx, midy+2*textheight("W"), <br>
modename); </p>
<p>/* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: getimage <br>
功 能: 将指定区域的一个位图存到主存中 <br>
用 法: void far getimage(int left, int top, int right,
int bottom, <br>
void far *bitmap); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> <br>
#include <alloc.h> </p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -