Windows API有,什麼都不用下載,是系統自帶的DLL。
授人以渔,不授人以鱼。
#include <stdio.h> #include <windows.h> #include <winuser.h> int main() { int a[10], b[10]; CreateCursor(HINSTANCE hInst, 10, 20, 4, 5, a, b); Sleep(2000); MessageBox(NULL, "Hello World!\n", "拥抱世界", MB_YESNOCANCEL); MessageBox(NULL, "Hello World!\n", "拥抱世界", MB_ICONASTERISK); return 0; }老大,CreateCursor的第一个参数应该怎么处理?比如我想在控制台窗口大约中间的位置创建一个指定了大小、位模式、热点的光标,貌似我上面的CreateCursor不起作用?把HINSTANCE hInst 改成 NULL 没反应改成数字又出错?
#include <assert.h> #include <stdlib.h> #include <stdio.h> typedef int int32_t; typedef void(*dummy)(void); #define BUG_ON(expr) assert(!(expr)) enum STR_ENUM_E { STR_TIPS_5MINS_E, STR_MAX_E }; static const char *local_str[] = { "请在5分钟内完成唐诗组合任务!\n", "\n请用上面诗句对应的大写字母组织两个五言绝句:", "\n请输入四个大写字母,用空格间隔后回车:\n", "重复组合,得0分!\n", "你太厉害了,再接再厉!现在的分数是%d\n", "错误!得0分.\n", }; struct __timer { int32_t hour; int32_t min; int32_t sec; int32_t milsec; }; struct timer { struct __timer timer; void (*count_down)(void); void (*time_show)(void); void (*time_run)(void); void (*time_set)(int, int, int, int); }; struct timer* timer_init(void) { struct timer *t; t = malloc(sizeof(struct timer)); if (!t) return NULL; t->timer.hour = 0; t->timer.min = 0; t->timer.sec = 0; t->timer.milsec = 0; t->count_down = NULL; t->time_show = NULL; t->time_run = NULL; t->time_set = NULL; return t; } struct timer* timer_register(struct timer *t, void *pram) { struct timer *p = (struct timer *)pram; BUG_ON(t == NULL); if (pram == NULL) return NULL; t->timer.hour = p->timer.hour; t->timer.min = p->timer.min; t->timer.sec = p->timer.sec; t->timer.milsec = p->timer.milsec; t->count_down = p->count_down; t->time_show = p->time_show; t->time_run = p->time_run; t->time_set = p->time_set; return t; } int32_t timer_release(struct timer *t) { /*do sth else*/ free(t); return 0; } static void count_down(void); static void time_show(void); static void time_run(void); static void time_set(void); /* void poem_store(void); void poem_show(char letter, char a[10]); */ int main(int argc, char *argv[]) { void *pram[] = {0, 0, 10, 0, count_down, time_show, time_run, time_set}; struct timer *timer = timer_init(); timer_register(timer, pram); timer_release(timer); printf(local_str[STR_TIPS_5MINS_E]); #if 0 char array[10], check[2]; char letter; int h = 0, m = 0, s = 2; int i, j = 2, score = 0; printf("请在5分钟内完成唐诗组合任务!\n"); struct timer timer; a.time_set(h, m, s); a.time_run(); printf("\n"); poem_store(); printf("\n请用上面诗句对应的大写字母组织两个五言绝句:"); while(j--) { printf("\n请输入四个大写字母,用空格间隔后回车:\n"); for (i = 0; i < 4 && EOF != scanf(" %c", &letter); i++) { poem_show(letter, array); } array[i] = 0; check[j] = array[0]; if (strcmp(array,"star") == 0 || strcmp(array, "foug") == 0) { if (check[1] == check[0]) printf("重复组合,得0分!\n"); else { score += 15; printf("你太厉害了,再接再厉!现在的分数是%d\n", score); } } else printf("错误!得0分.\n"); } printf("稍等片刻……\n"); Sleep(3000); system("cls"); poem_store(); printf("\n请用上面诗句对应的大写字母组织一个五言律诗:"); printf("\n请输入八个大写字母,用空格间隔后回车:"); for (i = 0; i < 8 && EOF != scanf(" %c", &letter); i++) { poem_show(letter, array); } array[i] = 0; if (strcmp(array,"bmecknyz") == 0 ) { score += 30; printf("你太厉害了,再接再厉!现在的分数是%d\n", score); } else printf("错误!得0分.\n"); printf("稍等片刻……\n"); Sleep(3000); system("cls"); poem_store(); printf("\n请用上面诗句对应的大写字母组织一个五言乐府:"); printf("\n请输入十个大写字母,用空格间隔后回车:"); for (i = 0; i < 10 && EOF != scanf(" %c", &letter); i++) { poem_show(letter, array); } array[i] = 0; if (strcmp(array,"wjhpdilqvx") == 0 ) { score += 40; printf("你太厉害了!现在的分数是%d\n", score); } else printf("错误!得0分.\n"); if (h == 0 && m == 0 && s == 0) { printf("时间到!你的成绩是%d分\n", score); Sleep(3000); exit(0); } #endif return 0; } #if 0 void poem_store() { printf("A:本来无一物B:百川东到海C:常恐秋节至D:荡胸生层云E:何处惹尘埃\n"); printf("F:两句三年得G:归卧故山丘H:何时复西归I:岱宗夫如何J:决眦入归鸟\n"); printf("K:焜黄华叶衰L:老大徒伤悲M:明镜亦非台N:一吟双泪流O:知音如不赏\n"); printf("P:菩提本无树Q:青青园中葵R:齐鲁青未了S:少壮不努力T:造化钟神秀\n"); printf("U:会当凌绝顶V:一览众山小W:万物生光辉X:阴阳割昏晓Y:阳春布德泽Z:朝露待日晞\n"); } void poem_show(char letter, char a[10]) //char a[10] is wasteful, use bitmap declare { switch (letter) { case 'A': printf("本来无一物\n"); a[2] = 'a'; break; case 'B': printf("百川东到海\n"); a[6] = 'l'; break; case 'C': printf("常恐秋节至\n"); a[4] = 'd'; break; case 'D': printf("荡胸生层云\n"); a[4] = 'k'; break; case 'E': printf("何处惹尘埃\n"); a[3] = 'r'; break; case 'F': printf("两句三年得\n"); a[0] = 'f'; break; case 'G': printf("归卧故山丘\n"); a[3] = 'g'; break; case 'H': printf("何时复西归\n"); a[7] = 'q'; break; case 'I': printf("岱宗夫如何\n"); a[0] = 'b'; break; case 'J': printf("决眦入归鸟\n"); a[5] = 'n'; break; case 'K': printf("焜黄华叶衰\n"); a[5] = 'i'; break; case 'L': printf("老大徒伤悲\n"); a[9] = 'x'; break; case 'M': printf("明镜亦非台\n"); a[1] = 't'; break; case 'N': printf("一吟双泪流\n"); a[1] = 'o'; break; case 'O': printf("知音如不赏\n"); a[2] = 'u'; break; case 'P': printf("菩提本无树\n"); a[0] = 's'; break; case 'Q': printf("青青园中葵\n"); a[0] = 'w'; break; case 'R': printf("齐鲁青未了\n"); a[1] = 'm'; break; case 'S': printf("少壮不努力\n"); a[8] = 'v'; break; case 'T': printf("造化钟神秀\n"); a[2] = 'e'; break; case 'U': printf("会当凌绝顶\n"); a[6] = 'y'; break; case 'V': printf("一览众山小\n"); a[7] = 'z'; break; case 'W': printf("万物生光辉\n"); a[3] = 'p'; break; case 'X': printf("阴阳割昏晓\n"); a[3] = 'c'; break; case 'Y': printf("阳春布德泽\n"); a[2] = 'h'; break; case 'Z': printf("朝露待日晞\n"); a[1] = 'j'; break; default: printf("哦米拖佛,施主请输入大写字母\n"); break; } } #endif void count_down(void) { } void time_show(void) { } void time_run(void) { } void time_set(void) { }LZ童鞋,我帮你把设计改了一下,看着干净一点