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

📄 mginit.c

📁 minigui实现带背景图片的主窗口的例子
💻 C
字号:
/*** $Id: mginit.c,v 1.46 2007-08-30 02:02:03 xwyan Exp $**** The mginit program of MiniGUI Demostration Envirionment.**** Copyright (C) 2001, 2002 Wei Yongming.** Copyright (C) 2003 ~ 2007 Feynman Software.**** Create date: 2001/09/05*//***  This source is free software; you can redistribute it and/or**  modify it under the terms of the GNU General Public**  License as published by the Free Software Foundation; either**  version 2 of the License, or (at your option) any later version.****  This software is distributed in the hope that it will be useful,**  but WITHOUT ANY WARRANTY; without even the implied warranty of**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU**  General Public License for more details.****  You should have received a copy of the GNU General Public**  License along with this library; if not, write to the Free**  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,**  MA 02111-1307, USA*/#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>#include <minigui/control.h>#include <minigui/mgext.h>#include <minigui/fixedmath.h>#ifndef _LITE_VERSION    #error "*******************************************************************"    #error "**** Your MiniGUI is configured as MiniGUI-Threads.            ****"    #error "**** This program is a server of MiniGUI-Processes,            ****"    #error "****   it can only run on MiniGUI-Processes,                   ****"    #error "****   not on MiniGUI-Threads.                                 ****"    #error "**** If you want to configure MiniGUI as MiniGUI-Processes,    ****"    #error "****   please run `./configure --enable-procs'                 ****"    #error "****   when configuring MiniGUI                                ****"    #error "****   and build and reinstall MiniGUI.                        ****"    #error "**** Note that this is not a fatal error.                      ****"    #error "*******************************************************************"#else#include "mainwndow.h"//static HWND hMainwinDlg;static void Usage (void){    MessageBox (HWND_DESKTOP,             "Please start 'mginit' from the directory in which it located! "            "Do not change to other directory to run it.\n\n"            "Thanks a lot.",            "Usage of MDE!",            MB_OK | MB_ICONEXCLAMATION);}static const char* new_del_client_info [] ={    NULL,    "New comming in client: %s\n",    "Disconnecting client: %s\n"};static void on_new_del_client (int op, int cli){    static int nr_clients = 0;    MG_Client* client = mgClients + cli;    if (op > 0 && op <= LCO_DEL_CLIENT)        printf (new_del_client_info [op], client?client->name:"NULL");    if (op == LCO_NEW_CLIENT) {        nr_clients ++;    }    else if (op == LCO_DEL_CLIENT) {        nr_clients --;        if (nr_clients == 0) {#if 0            SendMessage (hMainWnd, MSG_CLOSE, 0, 0);#else            printf ("There is no any client.\n");			//quit=TRUE;#endif        }        else if (nr_clients < 0) {            printf ("Serious error: nr_clients less than zero.\n");        }    }    else        printf ("Serious error: incorrect operations.\n");}static void child_wait (int sig){    int pid;    int status;    while ((pid = waitpid (-1, &status, WNOHANG)) > 0) {        if (WIFEXITED (status))            printf ("--pid=%d--status=%x--rc=%d---\n",                             pid, status, WEXITSTATUS(status));        else if (WIFSIGNALED(status))            printf ("--pid=%d--signal=%d--\n", pid, WTERMSIG (status));    }}int MiniGUIMain (int args, const char* arg[]){    int pid_desktop, status;    struct sigaction siga;    MSG Msg;    MAINWINCREATE CreateInfo;    HWND hMainWnd;	/* 初始化全局函数指针 */    OnNewDelClient = on_new_del_client;	//监视是否有新的客户端连接或断开    //OnChangeLayer = on_change_layer;	//监视是否有新的层加入或删除	/* 初始化服务器 */    if (!ServerStartup (0, 0, 0)) {        fprintf (stderr,                  "Can not start the server of MiniGUI-Processes: mginit.\n");        return 1;    }	/* 初始化mgext库 */    if (!InitMiniGUIExt ()) {        fprintf (stderr, "Can not init mgext library.\n");        return 1;    }/*	//把该行代码移到需要输入法的程序主函数中,参考mde包中notebook程序#ifdef _IME_GB2312    GBIMEWindow (HWND_DESKTOP);	#endif*/	/* 创建主窗口对话框 */    if ((hMainWnd = InitMainWindow ()) == HWND_INVALID) {        fprintf (stderr, "Can not create main window dialogbox.\n");        return 2;    }	/* 捕获SIGCHLD信号,以避免在子进程退出时因为没有进程获取其退出状态而形成僵尸进程 */    siga.sa_handler = child_wait;    siga.sa_flags  = 0;    memset (&siga.sa_mask, 0, sizeof(sigset_t));    sigaction (SIGCHLD, &siga, NULL);	/* mginit消息循环,收到MSG_QUIT退出 */    while (GetMessage (&Msg, hMainWnd)) {		TranslateMessage(&Msg);        DispatchMessage (&Msg);    }	/* 清理mgext库占用的资源 */    MiniGUIExtCleanUp ();    return 0;}#endif

⌨️ 快捷键说明

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