📄 ex06.c
字号:
/*
Example program for the NEO SDK, by Dong Kai.
http://neo.coderlife.net
ckerhome@yahoo.com.cn
这个程序演示了如何通过加载时钟例程来使用鼠标
你可以试着单击、双击、右击按键的操作来看看有什么效果
*/
#include "neo.h"
main()
{
neo_init();
set_video_mode(640, 480, 8, 75, 0); /*进入640X480,8位图形模式*/
install_mouse(); /*安装高级鼠标例程*/
_install_timer(); /*加载时钟例程,它绑定了鼠标状态刷新函数*/
change_timer(40);/*修改时钟中断的触发频率为40HZ*/
clear_to_color(_DARKGRAY); /*以灰色清屏*/
text_mode(_DARKGRAY); /*设置文字背景色*/
set_str_color(_YELLOW); /*设置文字显示颜色为黄色*/
textout("The mouse test, press any key to exit...", 5, 5);
while (!kbhit()) /*按任意键退出循环*/
{
/*画立体按钮*/
line(300, 219, 340, 219, 15);
line(299, 220, 299, 260, 15);
line(341, 220, 341, 260, 20);
line(300, 261, 340, 261, 20);
switch (get_click_info())
{
case 1: /*你单击了左键*/
scare_mouse();
rectfill(0, 0, 360, 16, _DARKGRAY);
rectfill(300, 220, 340, 260, _LIGHTBLUE);
textout("You click the left button", 5, 5);
unscare_mouse();
break;
case 2: /*你单击了右键*/
scare_mouse();
rectfill(0, 0, 360, 16, _DARKGRAY);
rectfill(300, 220, 340, 260, _LIGHTGREEN);
textout("You click the right button", 5, 5);
unscare_mouse();
break;
case 3: /*同时按下左右键*/
scare_mouse();
rectfill(0, 0, 360, 16, _DARKGRAY);
rectfill(300, 220, 340, 260, _LIGHTCYAN);
textout("You click the left&right button", 5, 5);
unscare_mouse();
break;
case 5: /*双击*/
scare_mouse();
rectfill(0, 0, 360, 16, _DARKGRAY);
rectfill(300, 220, 340, 260, _LIGHTMAGENTA);
textout("You click double the left button", 5, 5);
unscare_mouse();
break;
default:
break;
}
LOOP_END_OF_TIMER(); /*这个可别漏了哦~*/
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -