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

📄 dlg.c

📁 在smartarmm2200上显示波形实现暂停退出的功能
💻 C
字号:
/***************************************************************************** 文件名:Dlg.C* 功能:MiniGUI应用例子。*       建立一个模式对话框,对话框包括2个命令按钮和1个静态文本框。* 说明:使用MiniGUI for uC/OS-II,使用ADS 1.2编译器。****************************************************************************//* 包含MiniGUI的配置头文件(编译配置选项) */#include "MiniGUI_config.h"/* 包含MiniGUI头文件 */#include "common.h"#include "minigui.h"#include "gdi.h"#include "window.h"#include "control.h"/* 主窗口起始位置及大小 */#define  MWINDOW_LX	5       /* 窗口左边框的x值 */#define  MWINDOW_TY	50      /* 窗口上边框的y值 */#define  MWINDOW_RX	235     /* 窗口右边框的x值 */#define  MWINDOW_BY	200     /* 窗口下边框的y值 *//* 定义静态文本框的ID */#define  IDC_DISP1	1001HWND  hMainWnd;     // 主窗口句柄/* 对话框属性设置 */static  DLGTEMPLATE  DlgInitProgress ={   WS_BORDER | WS_CAPTION, // 风格    WS_EX_NONE,             // 扩展风格    10, 10, 200, 130,       // 对话框起始坐标,宽度、高度    "Dlg demo",             // 对话框标题     0,                      // 图标    0,                      // 菜单    3,                      // 内含控件个数    NULL,                   // 控件对象的地址    0                       // 附加数据};/* 对话框内的控件定义 */static CTRLDATA CtrlInitData[] = {       {   "static",        WS_VISIBLE | SS_SIMPLE,	    10,30,  160, 16,	    IDC_DISP1,	    "This is MiniGUI dlg!",	    0,        WS_EX_NONE    },        {   "button",        WS_TABSTOP | WS_VISIBLE | BS_DEFPUSHBUTTON,        30,70,  60,25,        IDOK,        "OK",        0,        WS_EX_NONE    },        {   "button",        WS_TABSTOP | WS_VISIBLE,        110,70, 60,25,        IDCANCEL,        "CANCEL",        0,        WS_EX_NONE    }};/***************************************************************************** 名称:DialogBoxProc()* 功能:对话框过程函数。*       处理MSG_COMMAND消息,执行命令按钮的功能。* 入口参数:hWnd        窗口句柄*           message     消息*           wParam      消息附加参数1*           lParam      消息附加参数2* 出口参数:返回消息处理结果。****************************************************************************/static int  DialogBoxProc(HWND hdlg, int message, WPARAM wParam, LPARAM lParam){   switch(message)    {   case MSG_INITDIALOG:           return(1);	          case MSG_COMMAND:	        switch(wParam)	        {   case IDOK:	            case IDCANCEL:	                EndDialog(hdlg, wParam);                    DestroyAllControls(hdlg);	                break;	        }	        break;    }        return(DefaultDialogProc(hdlg, message, wParam, lParam));}/***************************************************************************** 名称:InitDialogBox()* 功能:初始化对话框,然后启动对话框。 * 入口参数:hWnd        父窗口句柄* 出口参数:无****************************************************************************/static void  InitDialogBox(HWND hWnd){   DlgInitProgress.controls = CtrlInitData;    // 设置控件对象地址    /* 启动对话框"DlgInitProgress" */    DialogBoxIndirectParam(&DlgInitProgress, hWnd, DialogBoxProc, 0L);}/***************************************************************************** 名称:WinProc()* 功能:主窗口过程函数。*       当接收到MSG_LBUTTONDOWN消息,打开模式对话框。* 入口参数:hWnd        窗口句柄*           message     消息*           wParam      消息附加参数1*           lParam      消息附加参数2* 出口参数:消息已处理则返回0。****************************************************************************/static int  WinProc(HWND hWnd, int message, WPARAM wParam, LPARAM lParam){   HDC  hdc;    switch(message)    {   case MSG_PAINT:	        hdc = BeginPaint(hWnd);	        TextOut(hdc, 10, 50, "This is MiniGUI Window!");	        EndPaint(hWnd, hdc);            break;        case MSG_CLOSE:	        DestroyMainWindow(hWnd);	        PostQuitMessage(hWnd);	        break;        case MSG_LBUTTONDOWN:            InitDialogBox(hWnd);            break;        default:	        return(DefaultMainWinProc(hWnd, message, wParam, lParam));    }    return(0);}/***************************************************************************** 名称:InitMainWindow()* 功能:建立主窗口。* 入口参数:无* 出口参数:建立成功返回1,否则返回0。****************************************************************************/int InitMainWindow(void){   MAINWINCREATE  window_info;    window_info.dwStyle = WS_VISIBLE | WS_BORDER | WS_CAPTION;    window_info.dwExStyle = WS_EX_NONE;    window_info.spCaption = "WWW.ZLGMCU.COM";    window_info.hMenu = 0;    window_info.hCursor = GetSystemCursor(0);    window_info.hIcon = 0;    window_info.MainWindowProc = WinProc;    window_info.lx = MWINDOW_LX;    window_info.ty = MWINDOW_TY;    window_info.rx = MWINDOW_RX;    window_info.by = MWINDOW_BY;    window_info.iBkColor = COLOR_lightwhite;    window_info.dwAddData = 0;    window_info.hHosting = HWND_DESKTOP;         hMainWnd = CreateMainWindow (&window_info);    if (hMainWnd == HWND_INVALID) return(0);      else  return(1);}/***************************************************************************** 名称:MiniGUIMain()* 功能:MiniGUI程序入口点。* 入口参数:argc    参数个数*           argv    参数字符串指针* 出口参数:返回0。****************************************************************************/int  MiniGUIMain(int argc, const char *argv[]){   MSG Msg;#ifdef _LITE_VERSION    SetDesktopRect(0,0, 800,600);#endif    InitMainWindow();    ShowWindow(hMainWnd, SW_SHOWNORMAL);    while (GetMessage(&Msg, hMainWnd))     {   TranslateMessage(&Msg);        DispatchMessage(&Msg);    }        MainWindowThreadCleanup (hMainWnd);    return(0);}#ifndef _LITE_VERSION	#include "dti.c"#endif

⌨️ 快捷键说明

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