button

26 篇文章 0 订阅

/*
** $Id: button.c,v 1.16 2007-10-25 08:25:16 weiym Exp $
**
** Listing 20.1
**
** button.c: Sample program for MiniGUI Programming Guide
**     Usage of BUTTON control.
**
** Copyright (C) 2004 ~ 2007 Feynman Software.
**
** License: GPL
*/

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

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



#define IDC_STATIC_BIPS                  120        //波特率文本ID
#define IDC_STATIC_COM                 121       //串口文本ID
#define IDC_STATIC_DATADISPLAY    122       // 数据显示文本ID

#define IDC_CTRLBUTTON_115200    123        //复选框波特率115200
#define IDC_CTRLBUTTON_19200      124        //复选框波特率19200
#define IDC_CTRLBUTTON_9600        125        //复选框波特率9600
#define IDC_CTRLBUTTON_COM0     126        //复选框COM0
#define IDC_CTRLBUTTON_COM1     127        //复选框COM1

#define IDC_BUTTON_SEND              128        //接键发送
#define IDC_BUTTON_RECEIVE          129        //按键接收

#define IDC_TEXT_DATADISPLAY        130        //文本框数据显示



#define IDC_LAMIAN              101
#define IDC_CHOUDOUFU           102
#define IDC_JIANBING            103
#define IDC_MAHUA               104
#define IDC_SHUIJIAO            105

#define IDC_XIAN                110
#define IDC_LA                  111

#define IDC_PROMPT              200

static DLGTEMPLATE DlgYourTaste =
{
    WS_BORDER | WS_CAPTION,
    WS_EX_NONE,
    0, 0, 370, 280,
#ifdef _LANG_ZHCN
    "您喜欢吃哪种风味的小吃",
#else
    "What flavor snack do you like?",
#endif
    0, 0,
    12, NULL,
    0
};

static CTRLDATA MyContols[] =
{
    {
        "static",
        WS_VISIBLE,
        16, 10, 230, 160,
        IDC_STATIC_BIPS,
        "波特率选择",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_AUTORADIOBUTTON | BS_CHECKED | WS_TABSTOP | WS_GROUP,
        36, 38, 200, 20,
        IDC_CTRLBUTTON_115200,
        "115200",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_AUTORADIOBUTTON,
        36, 64, 200, 20,
        IDC_CTRLBUTTON_19200,
        "19200",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_AUTORADIOBUTTON,
        36, 90, 200, 20,
        IDC_CTRLBUTTON_9600,
        "9600",
        0
    },
    {
        "static",
        WS_VISIBLE,
        16, 116, 200, 20,
        IDC_STATIC_COM,
        "端口选择:",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_AUTORADIOBUTTON | BS_CHECKED | WS_TABSTOP | WS_GROUP,
        36, 140, 200, 20,
        IDC_CTRLBUTTON_COM0,
        "COM0",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_AUTORADIOBUTTON,
        36, 166, 200, 20,
        IDC_CTRLBUTTON_COM1,
        "COM1",
        0
    },
    {
        "static",
        WS_VISIBLE ,
        180, 10, 100, 160,
        IDC_STATIC_DATADISPLAY,
        "数据显示:",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_AUTOCHECKBOX | BS_CHECKED,
        260, 64, 80, 20,
        IDC_LA,
#ifdef _LANG_ZHCN
        "偏辣",
#else
        "Partial spicy",
#endif
        0
    },
    {
        "static",
        WS_VISIBLE | SS_LEFT | WS_GROUP,
        16, 180, 360, 20,
        IDC_PROMPT,
#ifdef _LANG_ZHCN
        "西北拉面是面食中的精品,但街上的兰州拉面除外!",
#else
        "Northwest pulled noodle is competitive product in the wheaten food",
#endif
        0
    },
    {
        "button",
        WS_VISIBLE | BS_DEFPUSHBUTTON | WS_TABSTOP | WS_GROUP,
        16, 200, 70, 28,
         IDC_BUTTON_SEND,
        "发送",
        0
    },
    {
        "button",
        WS_VISIBLE | BS_DEFPUSHBUTTON,
        100, 200, 70, 28,
         IDC_BUTTON_RECEIVE,
        "接收",
        0
    },
};

#ifdef _LANG_ZHCN
static char* prompts [] = {
    "西北拉面是面食中的精品,但街上的兰州拉面除外!",
    "长沙臭豆腐口味很独特,一般人适应不了。",
    "山东煎饼很难嚼 :(",
    "天津麻花很脆,很香!",
    "成都的红油水饺可真好吃啊!想起来就流口水。",
};
#else
static char* prompts [] = {
    "Northwest pulled noodle is competitive product in the wheaten food",
    "Changsha bad-smelling bean curd is very unique",
    "Shandong thin pancake is difficult to chew",
    "Tianjin fired dough twist is very fragile",
    "Chengdu red oil boiled dumpling is captivating",
};
#endif


static void my_notif_proc (HWND hwnd, int id, int nc, DWORD add_data)
{
    if (nc == BN_CLICKED) {
        SetWindowText (GetDlgItem (GetParent (hwnd), IDC_PROMPT), prompts [id - IDC_LAMIAN]);
    }
}

static int DialogBoxProc2 (HWND hDlg, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
    case MSG_INITDIALOG:
        {
            int i;
            for (i = IDC_STATIC_BIPS; i <= IDC_TEXT_DATADISPLAY; i++)
                SetNotificationCallback (GetDlgItem (hDlg, i), my_notif_proc);
        }
        return 1;
       
    case MSG_COMMAND:
        switch (wParam) {
        case IDOK:
        case IDCANCEL:
            EndDialog (hDlg, wParam);
            break;
        }
        break;
       
    }
   
    return DefaultDialogProc (hDlg, message, wParam, lParam);
}

int MiniGUIMain (int argc, const char* argv[])
{
#ifdef _MGRM_PROCESSES
    JoinLayer(NAME_DEF_LAYER , "button" , 0 , 0);
#endif
   
    DlgYourTaste.controls = MyContols;
   
    DialogBoxIndirectParam (&DlgYourTaste, HWND_DESKTOP, DialogBoxProc2, 0L);

    return 0;
}

#ifndef _LITE_VERSION
#include <minigui/dti.c>
#endif

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值