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

📄 helloworld.c

📁 用minigui做的helloworld程序
💻 C
字号:
#include <stdio.h>#include <string.h>#include <minigui/common.h>#include <minigui/minigui.h>#include <minigui/gdi.h>#include <minigui/window.h>#include <minigui/control.h>static int HelloWinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){  HDC hdc;  RECT rc;	char msg_text[30];	switch (message) {		//创建时发送的消息,用来做初始化处理,这里是初始化字符串内容        case MSG_CREATE:			strcpy(msg_text,"Hello, world!");            break;		//窗口绘画时发送的消息,用来在界面绘图或者输出文字		//注意这里的return 0 表明不需要进入默认处理函数中。        case MSG_PAINT:            printf ("BeginPaint.\n");            hdc = BeginPaint (hWnd);            TextOut (hdc, 10, 50, msg_text);            EndPaint (hWnd, hdc);            printf ("EndPaint.\n");            return 0;		//结束时一些处理函数,主要是销毁主窗口和发送quit消息以退出消息循环。        case MSG_CLOSE:            DestroyMainWindow (hWnd);            PostQuitMessage (hWnd);            return 0;    }    return DefaultMainWinProc(hWnd, message, wParam, lParam);}int MiniGUIMain (int argc, const char* argv[]){    MSG Msg;    HWND hMainWnd;    MAINWINCREATE CreateInfo;	//窗口信息    CreateInfo.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;  //风格    CreateInfo.dwExStyle = WS_EX_NONE;    CreateInfo.spCaption = "Hello, world!";                    //标题名    CreateInfo.hMenu = 0;                                      //无菜单    CreateInfo.hCursor = GetSystemCursor(0);    CreateInfo.hIcon = 0;    CreateInfo.MainWindowProc = HelloWinProc;                  //消息处理过程函数    CreateInfo.lx = 0;    CreateInfo.ty = 0;    CreateInfo.rx = 320;    CreateInfo.by = 240;    CreateInfo.iBkColor = COLOR_lightwhite;    CreateInfo.dwAddData = 0;    CreateInfo.hHosting = HWND_DESKTOP;                       //托管窗口       	//创建主窗口    hMainWnd = CreateMainWindow (&CreateInfo);                //创建主窗口          if (hMainWnd == HWND_INVALID)        return -1;	//显示主窗口    ShowWindow(hMainWnd, SW_SHOWNORMAL);                      //显示主窗口	//消息循环    while (GetMessage(&Msg, hMainWnd)) {                            TranslateMessage(&Msg);        DispatchMessage(&Msg);    }	//资源清理    MainWindowThreadCleanup (hMainWnd);    return 0;}

⌨️ 快捷键说明

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