WS_EX_NONE }, { \ WS_VISIBLE|WS_TABSTOP, 585,160,80,60, ID_LED4, \ 0, WS_EX_NONE }, { \ WS_VISIBLE|WS_TABSTOP, 285,360,80,60, ID_START, \ 0, WS_EX_NONE }, { \ WS_VISIBLE|WS_TABSTOP, 435,360,80,60, ID_STOP, \ 0, WS_EX_NONE }, {
CTRL_COMBOBOX, WS_VISIBLE|WS_TABSTOP|CBS_AUTOSPIN|CBS_AUTOLOOP,
/*CBS_AUTOSPIN创建旋钮数字框,CBS_AUTOLOOP框中的数字将自动循 环显示*/ 435,270,80,40, ID_COMBOBOX,
16
\ /*旋钮数字框初始值*/ 0, WS_EX_NONE } };
static int DialogBoxProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam) /*对话框过程函数,用来接收和处理所有发送到该窗口的消息*/ {
int number; /*用来存从旋钮数字框获得的数值*/ static int t=0;
int num; /*存放定时时间*/ switch(message) {
case MSG_INITDIALOG:
/*用户在定义自己的对话框回调函数时,需要处理 MSG_INITDIALOG消息,该消息是在 MiniGUI根据对话框模板建立对话框以及 控件之后 ,发送到对话框回调函数的 。*/ SendDlgItemMessage(hWnd, ID_COMBOBOX, CB_SETSPINRANGE, 0, 10000); /*设置旋钮数字框的最大小值*/ return 1; case MSG_PAINT:/*重绘消息*/ draw_circular(hWnd,175,90,30,1); draw_circular(hWnd,325,90,30,1); draw_circular(hWnd,475,90,30,1); draw_circular(hWnd,625,90,30,1); printf(\draw_circular******************************\\n\ case MSG_TIMER:t++; /*定时器消息,这里完成LED灯的闪烁*/ if(t%2!=0) { ioctl(fd_led, 0,0); ioctl(fd_led, 0, 1); ioctl(fd_led, 0, 2); ioctl(fd_led, 0, 3); printf(\
17
draw_circular(hWnd,175,90,30,1); draw_circular(hWnd,325,90,30,1); draw_circular(hWnd,475,90,30,1); draw_circular(hWnd,625,90,30,1); break; } else { ioctl(fd_led, 1,0); ioctl(fd_led, 1, 1); ioctl(fd_led, 1, 2); ioctl(fd_led, 1, 3); printf(\ draw_circular(hWnd,175,90,30,0); draw_circular(hWnd,325,90,30,0); draw_circular(hWnd,475,90,30,0); draw_circular(hWnd,625,90,30,0); break; } case MSG_COMMAND: /*击键消息*/ switch (wParam) { case ID_LED1:a++; /*控制LED灯亮暗*/ if(a%2!=0) {
ioctl(fd_led,0,0); draw_circular(hWnd,175,90,30,1); } else {
/ ioctl(fd_led,1,0); draw_circular(hWnd,175,90,30,0); }
printf(\
18
break; case ID_LED2:b++; if(b%2!=0) {
ioctl(fd_led,0,1); draw_circular(hWnd,325,90,30,1); } else {
ioctl(fd_led,1,1); draw_circular(hWnd,325,90,30,0); }
printf(\ break; case ID_LED3:c++; if(c%2!=0) {
ioctl(fd_led,0,2); draw_circular(hWnd,475,90,30,1); } else {
ioctl(fd_led,1,2); draw_circular(hWnd,475,90,30,0); }
printf(\ break; case ID_LED4:d++; if(d%2!=0) {
ioctl(fd_led,0,3); draw_circular(hWnd,625,90,30,1);
19
printf(\ } else {
ioctl(fd_led,1,3); draw_circular(hWnd,625,90,30,0 ); } printf(\ break; case
ID_START:printf(\
number=SendMessage(GetDlgItem(hWnd,ID_COMBOBOX), CB_GETSPINVALUE, 0, 0);/*获取旋钮数字框的数值*/ printf(\
printf(\ if(number!=0) {
printf(\ num=(int)(1000*(1.0/number)); /*将频率转换为时间*/
printf(\ } else { printf(\ num=1000; }
20