minigui对话框+按键列表demo(加注释)

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>

#define IDC_1              100
#define IDC_2             101
#define IDC_3             102
#define IDC_4             103

static DLGTEMPLATE DlgFistWin =
{
    WS_BORDER | WS_CAPTION |WS_MINIMIZEBOX  | WS_MAXIMIZEBOX,   //WS_CAPTION有题栏  WS_BORDER有边框  WS_MINIMIZEBOX最小化
    WS_EX_AUTOSECONDARYDC,
    0, 0, 800, 480,         //x y w h
    "this is static demo",  //标题
    0, 0,
    5,                       //窗口个数
	NULL,  
    0
};

static CTRLDATA SetDialogArr[] =
{ 
    {
        "button",
        WS_VISIBLE | BS_AUTORADIOBUTTON | BS_CHECKED | WS_TABSTOP | WS_GROUP,  //BS_CHECKED 初始选中
        20, 28, 200, 20, 
        IDC_1, 
        "1",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_AUTORADIOBUTTON,   //WS_VISIBLE 初始化可见  BS_AUTORADIOBUTTON显示用户的选择
        20, 48, 200, 20,
        IDC_2,
        "2",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_AUTORADIOBUTTON, 
        20, 68, 200, 20, 
        IDC_3, 
        "3",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_AUTORADIOBUTTON,  
        20, 88, 200, 20, 
        IDC_4 ,
        "4",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,  //BS_PUSHBUTTON 按下   WS_TABSTOP tab停止
        120, 230, 100, 30,
        IDCANCEL,
        "Exit",
        0
    },
};


static int DialogBlackProc(HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
	struct _DepInfo *info;
    switch (message) {	
	//定义自己的对话框回调函数时,需要处理 MSG_INITDIALOG 消息
    case MSG_INITDIALOG:
        info = (struct _DepInfo*)lParam;
		//数据初始化对话框 
		SetWindowAdditionalData (hDlg, (DWORD)lParam);
		break;
	//窗口空闲无事件发生的时候,会一直不停的发送该消息给主窗口
    case MSG_IDLE:
       
        break;

	//监控修改
    case MSG_COMMAND:
        switch (wParam) {
		case IDOK:
				// 使用 info 结构中的数据 
        case IDCANCEL:
            EndDialog (hDlg, wParam);
            break;
        }
        break;
    }

    return DefaultDialogProc (hDlg, message, wParam, lParam);
}

int MiniGUIMain (int argc, const char* argv[])
{
#ifdef _MGRM_PROCESSES
	// MiniGUI-Processes  模式下加入层
    JoinLayer(NAME_DEF_LAYER , "hello" , 0 , 0);
#endif
	//设置为默认渲染器 一共四种渲染器classic、flat、fashion、skin
    SetDefaultWindowElementRenderer ("skin");

	//对话框 controls指向定义控件的数组
    DlgFistWin.controls = SetDialogArr;
	
	//创建托管窗口为桌面窗口的对话框
    DialogBoxIndirectParam (&DlgFistWin, HWND_DESKTOP, DialogBlackProc, 0L);

    return 0;
}

效果图
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_小白鱼儿_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值