请输入您要查询的百科知识:

 

词条 getbkcolor
释义

函数原型: int fat getbkcolor(void)

函数功能: 得到当前背景颜色

函数返回: 颜色值含义如下:

0 - BLACK 黑 深色0 - 7

1 - BLUE 兰

2 - GREEN 绿

3 - CYAN 青

4 - RED 红

5 - MAGENTA 洋红

6 - BROWN 棕

7 - LIGHTGRAY 淡灰

8 - DARKGRAY 深灰 淡色8 - 15

9 - LIGHTBLUE 淡兰

10 - LIGHTGREEN 淡绿

11 - LIGHTCYAN 淡青

12 - LIGHTRED 淡红

13 - LIGHTMAGENTA 淡洋红

14 - YELLOW 黄

15 - WHITE 白

程序例:

#include <graphics.h>

#include <stdlib.h>

#include <string.h>

#include <stdio.h>

#include <conio.h>

int main(void)

{

/* request auto detection */

int gdriver = DETECT, gmode, errorcode;

int bkcolor, midx, midy;

char bkname[35];

/* initialize graphics and local variables */

initgraph(&gdriver, &gmode, "");

/* read result of initialization */

errorcode = graphresult();

/* an error occurred */

if (errorcode != grOk)

{

printf("Graphics error: %s\",

grapherrormsg(errorcode));

printf("Press any key to halt:");

getch();

/* terminate with an error code */

exit(1);

}

midx = getmaxx() / 2;

midy = getmaxy() / 2;

setcolor(getmaxcolor());

/* for centering text on the display */

settextjustify(CENTER_TEXT, CENTER_TEXT);

/* get the current background color */

bkcolor = getbkcolor();

/* convert color value into a string */

itoa(bkcolor, bkname, 10);

strcat(bkname,

" is the current background color.");

/* display a message */

outtextxy(midx, midy, bkname);

/* clean up */

getch();

closegraph();

return 0;

}

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2025/3/14 19:24:19