VC++ mfc绘制了一个仪表盘控件

VC++ mfc绘制了一个仪表盘控件,第1张

用ATL编程做吧,只做个ACTIVEX控件,就可以嵌入到你的窗口里了。不需要用类导出函数的。微软的Ofiice和IE网页都提供了这个共能,可以让开发人员将EXCEL或IE窗口,嵌入至自己的窗口中。

#include <stdio.h>

void main()

{

double f,c,b

scanf("请输入华氏温度: %f\n",&f)

c=f-32

b=5.00/9

c=b*c

printf("对应的摄氏温度为: %f\n",c)

}

/* Note:Your choice is C IDE */

#include "stdio.h"

#include "graphics.h"

#include "math.h"

#include "time.h"

#include "dos.h"

#include "stdlib.h"

#include "conio.h"

#define R 200

#define PI 3.1415926

#define X(a,b,c) x=a*cos(b*c*PI/180-PI/2)+300

#define Y(a,b,c) y=a*sin(b*c*PI/180-PI/2)+240

#define d(a,b,c) X(a,b,c)Y(a,b,c)line(300,240,x,y)

void init(void)

void draw_bp(void)

void close(void)

void draw_kt(void)

int main(void)

{

int x,y,hc=0

int bx,by,ax,ay

int h,m,s

struct time t[1]

init()

draw_bp()

draw_kt()

setwritemode(1)

gettime(t)

h=t[0].ti_hour

m=t[0].ti_min

s=t[0].ti_sec

setcolor(7)

d(150,h,30)

setcolor(14)

d(170,h,6)

setcolor(4)

d(190,s,6)

while(!kbhit())

{

while(t[0].ti_sec==s)

gettime(t)

sound(400)

delay(70)

sound(200)

delay(30)

nosound()

setcolor(4)

d(190,s,6)

s=t[0].ti_sec

setfillstyle(SOLID_FILL,13)

floodfill(1,380,14)

setcolor(4)

d(190,s,6)

if(t[0].ti_min!=m)

{

setcolor(14)

d(170,m,6)

m=t[0].ti_min

d(170,m,6)

}

if(t[0].ti_hour!=h)

{

setcolor(7)

d(150,h,30)

h=t[0].ti_hour

d(150,h,30)

sound(1000)

delay(240)

nosound()

delay(140)

sound(2000)

delay(240)

nosound()

}

setcolor(hc++)

if(hc==12) hc=0

ellipse(300,300,160,340,23,23)

ellipse(220,170,0,360,23,65)

ellipse(380,170,0,360,23,65)

ellipse(300,180,0,180,23,23)

ellipse(380,180,0,180,23,23)

arc(150,80,20,250,59)

}

close()

return 0

}

void init(void)

{

int driver,mode

driver=DETECT

initgraph(&driver,&mode,"c:\\tc")

cleardevice()

}

void draw_bp(void)

{

int x=300,y=240,i,n,l,ax,ay,bx,by

for(n=0n<27n++)

printf("\n")

for(n=0n<29n++)

printf(" ")

setbkcolor(0)

setcolor(14)

circle(x,y,R)

setcolor(12)

circle(x,y,190)

setfillstyle(SOLID_FILL,14)

floodfill(x,y,12)

setfillstyle(SOLID_FILL,13)

floodfill(1,1,14)

setcolor(2)

circle(x,y,2)

circle(x,y,5)

for(i=0i<60i++)

{

if(i%5==0)

l=15

else

l=5

ax=200*cos(i*6*PI/180)+300

ay=200*sin(i*6*PI/180)+240

bx=(200-l)*cos(i*6*PI/180)+300

by=(200-l)*sin(i*6*PI/180)+240

line(ax,ay,bx,by)

}

settextstyle(3,0,5)

outtextxy(260,380,"MADEIN CHINA")

}

void draw_kt(void)

{

int x=300,y=240

ellipse(x-80,y-70,0,360,23,65)

ellipse(x+80,y-70,0,360,23,65)

ellipse(x-80,y-60,0,180,23,23)

setfillstyle(SOLID_FILL,0)

floodfill(x-80,y-60,2)

ellipse(x+80,y-60,0,180,23,23)

setfillstyle(SOLID_FILL,0)

floodfill(x+80,y-70,2)

setcolor(5)

circle(150,80,60)

setfillstyle(SOLID_FILL,14)

floodfill(150,80,5)

circle(450,80,60)

setfillstyle(SOLID_FILL,14)

floodfill(450,80,5)

setcolor(14)

arc(150,80,0,360,60)

arc(450,80,0,360,60)

setcolor(0)

ellipse(x,y+60,160,340,23,23)

circle(x+120,y+10,23)

setfillstyle(SOLID_FILL,12)

floodfill(x+120,y+10,0)

setcolor(14)

circle(x+120,y+10,23)

setcolor(0)

circle(x-120,y+10,23)

setfillstyle(SOLID_FILL,12)

floodfill(x-120,y+10,0)

setcolor(14)

circle(x-120,y+10,23)

ellipse(x,y+60,0,180,23,23)

}

void close(void)

{

getch()

closegraph()

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12202081.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存