硬汉嵌入式论坛

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

[emWin] 请教消息传递

[复制链接]

12

主题

22

回帖

58

积分

初级会员

积分
58
发表于 2013-10-15 14:42:31 | 显示全部楼层 |阅读模式
想实现定期检测外围key有按键时,向当前窗口发送相对应的按钮被单击的消息.比如STM32 GPIOA的pin0~2,分别对应的窗口上的Button0~2,检测到GPIOA那个端口为0时,相应的按钮就被按下.
下面是GUIBuilder产生的代码,如果修改成上面的功能?
/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.20                          *
*        Compiled Feb 19 2013, 15:01:37                              *
*        (c) 2013 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
#include "sys.h"
// USER END

#include "DIALOG.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0     (GUI_ID_USER + 0x05)
#define ID_BUTTON_0     (GUI_ID_USER + 0x06)
#define ID_BUTTON_1     (GUI_ID_USER + 0x07)
#define ID_BUTTON_2     (GUI_ID_USER + 0x08)
#define ID_TEXT_0     (GUI_ID_USER + 0x09)
#define ID_TEXT_1     (GUI_ID_USER + 0x0A)


// USER START (Optionally insert additional defines)
extern struct SystemInfo SysPar;
extern GUI_CONST_STORAGE GUI_FONT GUI_FontCHN16;
// USER END

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

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

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
  { FRAMEWIN_CreateIndirect, "Main", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 10, 20, 60, 30, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 10, 100, 60, 30, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_2, 10, 180, 60, 30, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_0, 90, 20, 200, 30, 0, 0x64, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_1, 90, 90, 200, 30, 0, 0x64, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

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

// USER START (Optionally insert additional static code)
#define TextMaxLen 32
struct{
    char *TextButton0;
    char *TextButton1;
    char *TextButton2;
    char *TextText0;
    char *TextText1;
    char *TextText2;
} WidgetText;
// USER END

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

  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:
    //
    // Initialization of 'Button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
         switch(SysPar.Language)
        {
            case 0:
                BUTTON_SetFont(hItem,&GUI_Font16_ASCII);
                BUTTON_SetText(hItem, "Test");
                break;
            case 1:
                BUTTON_SetFont(hItem,&GUI_FontCHN16);
                BUTTON_SetText(hItem, "测试");
                break;
        }            
    //
    // Initialization of 'Button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
         switch(SysPar.Language)
        {
            case 0:
                BUTTON_SetFont(hItem,&GUI_Font16_ASCII);
                BUTTON_SetText(hItem, "Setup");
                break;
            case 1:
                BUTTON_SetFont(hItem,&GUI_FontCHN16);
                BUTTON_SetText(hItem, "设置");
                break;
        }            
    //
    // Initialization of 'Button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
         switch(SysPar.Language)
        {
            case 0:
                BUTTON_SetFont(hItem,&GUI_Font16_ASCII);
                BUTTON_SetText(hItem, "About");
                break;
            case 1:
                BUTTON_SetFont(hItem,&GUI_FontCHN16);
                BUTTON_SetText(hItem, "关于");
                break;
        }            
    //
    // Initialization of 'Text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
    TEXT_SetText(hItem, "Start test resistance or resistivity");
    //
    // Initialization of 'Text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
    TEXT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
    TEXT_SetText(hItem, "Setup system parameter");
    // USER START (Optionally insert additional code for further widget initialization)
    // USER END
    break;
  case WM_NOTIFY_PARENT:
    Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
    switch(Id) {
    case ID_BUTTON_0: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_1: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    case ID_BUTTON_2: // Notifications sent by 'Button'
      switch(NCode) {
      case WM_NOTIFICATION_CLICKED:
        // USER START (Optionally insert code for reacting on notification message)
        // USER END
        break;
      case WM_NOTIFICATION_RELEASED:
        // USER START (Optionally insert code for reacting on notification message)
                CreateAboutWindow();
        // USER END
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;
    // USER START (Optionally insert additional code for further Ids)
    // USER END
    }
    break;
  // USER START (Optionally insert additional message handling)
  // USER END
  default:
    WM_DefaultProc(pMsg);
    break;
  }
}

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateMain
*/
WM_HWIN CreateMain(void);
WM_HWIN CreateMain(void) {
  WM_HWIN hWin;

  hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
  return hWin;
}

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

/*************************** End of file ****************************/
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
107262
QQ
发表于 2013-10-15 14:51:27 | 显示全部楼层
外部按键控制控件没有搞过,emWin有个自己的专门处理方面,楼主可以先看下手册里面讲键盘的那个章节,
最近我也会学习一下,后面专门推出一个教程的。
回复

使用道具 举报

12

主题

22

回帖

58

积分

初级会员

积分
58
 楼主| 发表于 2013-10-15 20:03:53 | 显示全部楼层
看了下emwin的说明,目前知道有两个方法。
1.使用指针输入设备API,GUI_PID_StoreState()
2.使用键盘输入API,GUI_StoreKey()
回复

使用道具 举报

12

主题

22

回帖

58

积分

初级会员

积分
58
 楼主| 发表于 2013-10-15 20:04:17 | 显示全部楼层
看了下emwin的说明,目前知道有两个方法。
1.使用指针输入设备API,GUI_PID_StoreState()
2.使用键盘输入API,GUI_StoreKey()
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-23 14:37 , Processed in 0.274390 second(s), 26 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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