⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 这是一个minigui 最简单的 服务器 ,如果需要可以自己扩展:).c

📁 MiniGUI1.6.9的窗口编程实例
💻 C
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <signal.h>#include <time.h>#include <sys/types.h>#include <sys/wait.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>static BOOL quit = FALSE;static void on_new_del_client (int op, int cli){   static int nr_clients = 0;   if (op == LCO_NEW_CLIENT) {       nr_clients ++;   }   else if (op == LCO_DEL_CLIENT) {       nr_clients --;       /* 当所有的 客户程 序都已 退出时 */       if (nr_clients == 0) {           printf ("There is no any client, I will quit.\n");          /* 置 quit 为 TRUE,导致消 息 循环终 止,mginit 程序退出 */           quit = TRUE;       }       else if (nr_clients < 0) {           printf ("Serious error: nr_clients less than zero.\n");       }   }   else       printf ("Serious error: incorrect operations.\n");}/* 启动客 户程 序 */static pid_t exec_app (const char* file_name, const char* app_name){   pid_t pid = 0;   if ((pid = vfork ()) > 0) {       fprintf (stderr, "new child, pid: %d.\n", pid);   }   else if (pid == 0) {       execl (file_name, app_name, NULL);       perror ("execl");       _exit (1);   }   else {       perror ("vfork");   }   return pid;}/* 上一次 有输 入事件 时的系 统滴答 时间 */static unsigned int old_tick_count;/* 屏幕保 护程 序的 PID */static pid_t pid_scrnsaver = 0;/* 服务器 事件 钩子 */static int my_event_hook (PMSG msg){   /* 用户按 下 F1 键时启 动不同 的程序 程序 */   if (msg->message == MSG_KEYDOWN) {       switch (msg->wParam) {           case SCANCODE_F1:              exec_app ("./listbox", "listbox");              break;       }   }   /* 让系统 继续处 理所有 事件 */   return HOOK_GOON;}int MiniGUIMain (int args, const char* arg[]){   MSG msg;   OnNewDelClient = on_new_del_client;   /* 初始化 服务器 程序 */   if (!ServerStartup(0,0,0)) {       fprintf (stderr, "Can not start mginit.\n");       return 1;   }   /* 设置服 务器事 件钩子 函数 */   SetServerEventHook (my_event_hook);   if (exec_app ("./helloworld", "helloworld") == 0)      return 3;   while (!quit && GetMessage (&msg, HWND_DESKTOP)) {       DispatchMessage (&msg);   }   return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -