硬汉嵌入式论坛

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

[emWin] EMWIN中的图标怎么当作按键BUTTON一样??

[复制链接]

1

主题

3

回帖

1

积分

新手上路

积分
1
发表于 2017-3-8 15:14:08 | 显示全部楼层 |阅读模式
1.png 2.png 3.png


/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.30                          *
*        Compiled Jul  1 2015, 10:50:32                              *
*        (c) 2015 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

// USER START (Optionally insert additional includes)
// USER END

#include "DIALOG.h"
#include "BUTTON.h"
/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_WINDOW_0    (GUI_ID_USER + 0x0C)
#define ID_BUTTON_0    (GUI_ID_USER + 0x0B)
#define ID_BUTTON_1    (GUI_ID_USER + 0x0E)
#define ID_TEXT_0      (GUI_ID_USER + 0x0F)
#define ID_BUTTON_SET  (GUI_ID_USER + 0x0D)
//void    BUTTON_SetBitmapEx    (BUTTON_Handle hObj, unsigned int Index, const GUI_BITMAP * pBitmap, int x, int y);
extern const GUI_BITMAP     bmSetup;



void WM_HideWindow(WM_HWIN hWin);  //隐藏窗口函数,hWin是窗口的句柄
void WM_ShowWindow(WM_HWIN hWin);  //显示窗口函数,hWin是窗口的句柄

// 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[] = {
  { WINDOW_CreateIndirect, "Window0", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 20, 130, 53, 53, 0, 0x0, 0 },
  { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 120, 130, 53, 53, 0, 0x0, 0 },
  { TEXT_CreateIndirect, "Text", ID_TEXT_0, 38, 31, 51, 25, 0, 0x64, 0 },
  // USER START (Optionally insert additional widgets)
  // USER END
};

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/
   // extern const GUI_BITMAP     bmSetup;
   // BUTTON_Handle hButton;
   // hButton = BUTTON_Create(10, 10, 100, 100, GUI_ID_BUTTON0, WM_CF_SHOW);
    //BUTTON_SetBitmapEx(ID_BUTTON_0, BUTTON_BI_UNPRESSED, &bmSetup, 5, 5);

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

/*********************************************************************
*
*       _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg) {
   WM_HWIN hItem;
//BUTTON_Handle hButton ;
//WM_HWIN  hButton
  int     NCode;
  int     Id ;
  int     ID  ;
  switch (pMsg->MsgId) {
  case WM_INIT_DIALOG:    //创建对话框后立即发送到对话框窗口

    //hItem = pMsg->hWin;
    hItem =  BUTTON_Create(220, 130, 53, 53, ID_BUTTON_SET, WM_CF_SHOW);
    BUTTON_SetBitmapEx  (hItem, BUTTON_BI_UNPRESSED, &bmSetup, 3, 3);
//  BUTTON_SetStreamedBitmapEx()
// BUTTON_SetStreamedBitmapEx(BUTTON_Handle hObj, unsigned int Index, const GUI_BITMAP_STREAM * pBitmap, int x, int y);
// BUTTON_SetBitmapEx        (BUTTON_Handle hObj, unsigned int Index, const GUI_BITMAP * pBitmap, int x, int y);

    BUTTON_SetText(hItem, "set");

    hItem = pMsg->hWin;
    WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x00FFFF80));

    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
    BUTTON_SetText(hItem, "setting");
    //
    // Initialization of 'Button'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
    BUTTON_SetText(hItem, "print");

    //
    // Initialization of 'Text'
    //
    hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
    TEXT_SetText(hItem, "home");
    TEXT_SetTextColor(hItem, GUI_MAKE_COLOR(0x00A00000));
    TEXT_SetFont(hItem, GUI_FONT_20_ASCII);
    // 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:

          GUI_EndDialog(pMsg->hWin, 0);
             WM_DeleteWindow(pMsg->hWin);   //  删除窗口0
          CreateWindow1(WM_HBKWIN);    //setting
        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:
          GUI_EndDialog(pMsg->hWin, 0);
             WM_DeleteWindow(pMsg->hWin);   //  删除窗口0
          CreateWindow2(WM_HBKWIN);    //setting

        // 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_SET: // 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:

          GUI_EndDialog(pMsg->hWin, 0);
             WM_DeleteWindow(pMsg->hWin);   //  删除窗口0
          CreateWindow1(WM_HBKWIN);    //setting
        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
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateWindow
*/
WM_HWIN CreateWindow0(void);
WM_HWIN CreateWindow0(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

主题

3

回帖

1

积分

新手上路

积分
1
 楼主| 发表于 2017-3-8 15:17:18 | 显示全部楼层
在case ID_BUTTON_SET: // 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:

          GUI_EndDialog(pMsg->hWin, 0);
             WM_DeleteWindow(pMsg->hWin);   //  删除窗口0
          CreateWindow1(WM_HBKWIN);    //setting
        break;
      // USER START (Optionally insert additional code for further notification handling)
      // USER END
      }
      break;


将图标按钮显示出来后,图标按钮不是跟BUTTON按钮一样的
回复

使用道具 举报

1

主题

3

回帖

1

积分

新手上路

积分
1
 楼主| 发表于 2017-3-8 15:17:52 | 显示全部楼层
没法切换窗口
回复

使用道具 举报

1

主题

3

回帖

1

积分

新手上路

积分
1
 楼主| 发表于 2017-3-8 15:19:57 | 显示全部楼层
用控制BUTTON按钮的程序,无法控制图标做的按钮?
这个是更改哪里?
或者图标按钮的程序框是什么样的
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
117617
QQ
发表于 2017-3-8 15:29:47 | 显示全部楼层
可以学习下我们的新版emWin教程,此章节:
https://forum.anfulai.cn/forum.php?mod=viewthread&tid=19834
88888.png
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-8-18 11:50 , Processed in 0.051576 second(s), 33 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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