硬汉嵌入式论坛

 找回密码
 立即注册
查看: 278|回复: 1
收起左侧

[emWin] 只有4个TEXT控件的EMIWN不进入WM_KEY?

[复制链接]

5

主题

6

回帖

21

积分

新手上路

积分
21
发表于 2024-4-15 16:13:14 | 显示全部楼层 |阅读模式
#include "DIALOG.h"
extern GUI_CONST_STORAGE GUI_FONT GUI_Fontfont28;
extern GUI_CONST_STORAGE GUI_FONT GUI_Fontfont24;
extern GUI_CONST_STORAGE GUI_FONT GUI_Fontfont18;
/*********************************************************************
*
*       Defines
*
**********************************************************************
*/

#define ID_FRAMEWIN_0         (GUI_ID_USER + 0x00)
#define ID_TEXT_0 (GUI_ID_USER + 0x02)
#define ID_TEXT_1 (GUI_ID_USER + 0x04)
#define ID_TEXT_2 (GUI_ID_USER + 0x06)
#define ID_TEXT_3 (GUI_ID_USER + 0x08)
#define ID_TEXT_4 (GUI_ID_USER + 0x0C)
// USER START (Optionally insert additional defines)
// USER END

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

// USER START (Optionally insert additional static data)
// USER END

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] =
{
        { FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, 800, 480, 0, 0, 0},
        { TEXT_CreateIndirect, "Text0", ID_TEXT_0, 2, 1, 159, 40, 0, 100, 0 },
        { TEXT_CreateIndirect, "Text1", ID_TEXT_1, 340, 50, 30, 150, 0, 100, 0 },
        { TEXT_CreateIndirect, "Text2", ID_TEXT_2, 408, 50, 30, 150, 0, 100, 0 },
        { TEXT_CreateIndirect, "Text3", ID_TEXT_3, 340, 232, 30, 150, 0, 100, 0 },
        { TEXT_CreateIndirect, "Text4", ID_TEXT_4, 408, 232, 30, 150, 0, 100, 0 },
        //{ GRAPH_CreateIndirect, "Graph0", ID_GRAPH_0, 75, 35, 253, 180, 0, 0x0, 0},
        //{ GRAPH_CreateIndirect, "Graph1", ID_GRAPH_1, 450, 35, 253, 180, 0, 0x0, 0},
        //{ GRAPH_CreateIndirect, "Graph2", ID_GRAPH_2, 75, 217, 253, 180, 0, 0x0, 0},
        //{ GRAPH_CreateIndirect, "Graph3", ID_GRAPH_3, 450, 217, 253, 180, 0, 0x0, 0},
};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/

// USER START (Optionally insert additional static code)
// USER END

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
  WM_HWIN hItem;
        GUI_UC_SetEncodeUTF8();
  // USER START (Optionally insert additional variables)
  // USER END

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Framewin'
    //
            //初始化FRAMEWIN
                hItem = pMsg->hWin;
    FRAMEWIN_SetTitleHeight(hItem, 80);
          FRAMEWIN_SetText(hItem, "参数曲线");
    FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
    FRAMEWIN_SetFont(hItem, &GUI_Fontfont28);
    FRAMEWIN_SetTextColor(hItem, 0x00000000);
                //
    // Initialization of 'Text0'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetText(hItem, "上下键翻页");
    TEXT_SetTextColor(hItem, 0x00000000);
    TEXT_SetFont(hItem, &GUI_Fontfont18);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
                //
    // Initialization of 'Text1'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetText(hItem, "高\n压\n曲\n线");
    TEXT_SetTextColor(hItem, 0x00000000);
    TEXT_SetFont(hItem, &GUI_Fontfont24);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
                //
    // Initialization of 'Text2'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
    TEXT_SetText(hItem, "脉\n搏\n波");
    TEXT_SetTextColor(hItem, 0x00000000);
    TEXT_SetFont(hItem, &GUI_Fontfont24);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
                //
    // Initialization of 'Text3'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
    TEXT_SetText(hItem, "低\n压\n曲\n线");
    TEXT_SetTextColor(hItem, 0x00000000);
    TEXT_SetFont(hItem, &GUI_Fontfont24);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
                //
    // Initialization of 'Text4'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
    TEXT_SetText(hItem, "脉\n率\n曲\n线");
    TEXT_SetTextColor(hItem, 0x00000000);
    TEXT_SetFont(hItem, &GUI_Fontfont24);
    TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
                // USER START (Optionally insert additional code for further widget initialization)
    // USER END
                break;
               
  case WM_KEY:
            switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key)
            {

                case GUI_KEY_ENTER:
                    GUI_EndDialog(pMsg->hWin,0);
                        User1_historicaldata();
                        break;
                case GUI_KEY_ESCAPE:
                    GUI_EndDialog(pMsg->hWin,0);
                                                                                CreateFramewin1();
                    break;
            }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateFramewin
*/
WM_HWIN User6_historicaldata(void);
WM_HWIN User6_historicaldata(void) {
  WM_HWIN hWin;

  hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, WM_HBKWIN, 10, 9);
  return hWin;
}


回复

使用道具 举报

5

主题

6

回帖

21

积分

新手上路

积分
21
 楼主| 发表于 2024-4-15 19:35:37 | 显示全部楼层
已经解决,是因为i控件全是TEXT,无法响应WM_KEY
修改办法:加入了一个大小是1X1的LISTVIEW控件
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-11-11 03:43 , Processed in 0.185241 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表