-
getbkcolor
鎖定
函數原型: int fat getbkcolor(void)
- 外文名
- getbkcolor
- 函數原型
- int fat getbkcolor(void)
- 函數功能
- 得到當前背景顏色
- 函數返回
- 顏色值含義
getbkcolor基本介紹
函數原型: int fat getbkcolor(void)
函數功能: 得到當前背景顏色
函數返回: 顏色值含義如下:
0 - BLACK 黑
1 - BLUE 藍
2 - GREEN 綠
3 - CYAN 青
4 - RED 紅
5 - MAGENTA 洋紅
6 - BROWN 棕
7 - LIGHTGRAY 淡灰
8 - DARKGRAY 深灰
9 - LIGHTBLUE 淡蘭
10 - LIGHTGREEN 淡綠
11 - LIGHTCYAN 淡青
12 - LIGHTRED 淡紅
13 - LIGHTMAGENTA 淡洋紅
14 - YELLOW 黃
getbkcolor程序例
#include<graphics.h> #include<stdlib.h> #include<string.h> #include<stdio.h> #include<conio.h> int main(void) { /*request auto detection*/ intgdriver=DETECT,gmode,errorcode; intbkcolor,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("Graphicserror:%s\n",grapherrormsg(errorcode)); printf("Press anykey 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(); return0; } 重編者 注:itoa(bkcolor,bkname,10); 並沒有使顏色值轉換成字符串。運行結果顯示:0 is the current background color.
- 參考資料
-
- 1. getbkcolor函數
- 詞條統計
-
- 瀏覽次數:次
- 編輯次數:12次歷史版本
- 最近更新: 申个大懒腰时代