硬汉嵌入式论坛

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

[emWin] 复选框控件设置为禁用后还可以聚焦?

[复制链接]

24

主题

83

回帖

155

积分

初级会员

积分
155
发表于 2018-12-25 10:55:19 | 显示全部楼层 |阅读模式
在模拟器上试的结果复选框控件设置为禁用后不能在聚焦,但是在我的板子上复选框控件设置为禁用后还可以聚焦,板子上使用的是emwin5.22版本。什么模拟器上的结果和实际的显示结果不一样呢?,我把程序附在后面了,是不是我使用的有问题呀?

/*********************************************************************
*                                                                    *
*                SEGGER Microcontroller GmbH & Co. KG                *
*        Solutions for real time microcontroller applications        *
*                                                                    *
**********************************************************************
*                                                                    *
* C-file generated by:                                               *
*                                                                    *
*        GUI_Builder for emWin version 5.22                          *
*        Compiled Jul  4 2013, 15:16:01                              *
*        (c) 2013 Segger Microcontroller GmbH & Co. KG               *
*                                                                    *
**********************************************************************
*                                                                    *
*        Internet: www.segger.com  Support: support@segger.com       *
*                                                                    *
**********************************************************************
*/

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

#include "DIALOG.h"

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0    (GUI_ID_USER + 0x00)
#define ID_CHECKBOX_0    (GUI_ID_USER + 0x01)
#define ID_CHECKBOX_1    (GUI_ID_USER + 0x02)
#define ID_CHECKBOX_2    (GUI_ID_USER + 0x03)
#define ID_CHECKBOX_3    (GUI_ID_USER + 0x04)
#define ID_CHECKBOX_4    (GUI_ID_USER + 0x05)
#define ID_CHECKBOX_5    (GUI_ID_USER + 0x06)
#define ID_BUTTON_0    (GUI_ID_USER + 0x07)


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

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

WM_HWIN CreateFramewin_Test(void);

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

/*********************************************************************
*
*       _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    { FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 62, 60, 360, 160, 0, 0x64, 0 },
    { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_0, 60, 30, 80, 20, 0, 0x0, 0 },
    { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_1, 150, 30, 80, 20, 0, 0x0, 0 },
    { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_2, 240, 30, 80, 20, 0, 0x0, 0 },
    { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_3, 60, 80, 80, 20, 0, 0x0, 0 },
    { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_4, 150, 80, 80, 20, 0, 0x0, 0 },
    { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_5, 240, 80, 80, 20, 0, 0x0, 0 },
    { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 126, 113, 80, 20, 0, 0x0, 0 },
    // USER START (Optionally insert additional widgets)
    // USER END
};

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

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

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

    switch (pMsg->MsgId) {
    case WM_KEY:
    {
        WM_KEY_INFO* pData = (WM_KEY_INFO*)(pMsg->Data.p);        //获得消息结构体中的按键消息
        switch (pData->Key)
        {
        case GUI_KEY_ESCAPE:                //按下ESCAPE键进入主菜单界面
            WM_DeleteWindow(pMsg->hWin);                //删除窗口
            break;
        case GUI_KEY_DOWN://对下一个控件聚焦
            WM_SetFocusOnNextChild(WM_GetClientWindow(pMsg->hWin));        //由于使用了框架窗口控件,必须先要获得客户端窗口句柄,才能进行焦点切换
            break;                                                                                                        //因为控件的父窗口是客户端窗口,而框架窗口是客户端窗口的父窗口
        case GUI_KEY_UP://对上一个控件聚焦
            WM_SetFocusOnPrevChild(WM_GetClientWindow(pMsg->hWin));
            break;
        }
    }
    break;
    case WM_INIT_DIALOG:
        //
        // Initialization of 'Framewin'
        //
        hItem = pMsg->hWin;
        FRAMEWIN_SetFont(hItem, GUI_FONT_16B_1);
        FRAMEWIN_SetText(hItem, "Framewin");
        FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
        //
        // Initialization of 'Checkbox'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_0);
        CHECKBOX_SetText(hItem, "Check");
        //
        // Initialization of 'Checkbox'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_1);
        CHECKBOX_SetText(hItem, "Check");
        //
        // Initialization of 'Checkbox'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_2);
        CHECKBOX_SetText(hItem, "Check");
        //
        // Initialization of 'Checkbox'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_3);
        CHECKBOX_SetText(hItem, "Check");
        //
        // Initialization of 'Checkbox'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_4);
        CHECKBOX_SetText(hItem, "Check");
        //
        // Initialization of 'Checkbox'
        //
        hItem = WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_5);
        CHECKBOX_SetText(hItem, "Check");
        
        
        WM_DisableWindow(WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_3));//指定窗口设置为禁用状态
        WM_DisableWindow(WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_4));//指定窗口设置为禁用状态
        WM_DisableWindow(WM_GetDialogItem(pMsg->hWin, ID_CHECKBOX_5));//指定窗口设置为禁用状态
        // 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_CHECKBOX_0: // Notifications sent by 'Checkbox'
            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;
            case WM_NOTIFICATION_VALUE_CHANGED:
                // 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_CHECKBOX_1: // Notifications sent by 'Checkbox'
            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;
            case WM_NOTIFICATION_VALUE_CHANGED:
                // 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_CHECKBOX_2: // Notifications sent by 'Checkbox'
            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;
            case WM_NOTIFICATION_VALUE_CHANGED:
                // 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_CHECKBOX_3: // Notifications sent by 'Checkbox'
            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;
            case WM_NOTIFICATION_VALUE_CHANGED:
                // 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_CHECKBOX_4: // Notifications sent by 'Checkbox'
            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;
            case WM_NOTIFICATION_VALUE_CHANGED:
                // 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_CHECKBOX_5: // Notifications sent by 'Checkbox'
            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;
            case WM_NOTIFICATION_VALUE_CHANGED:
                // 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_0: // Notifications sent by 'Button'
            switch(NCode) {
            case WM_NOTIFICATION_CLICKED:
//                WM_DeleteWindow(pMsg->hWin);                //删除窗口
                GUI_EndDialog(pMsg->hWin, 0);
                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;
            // 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
*
**********************************************************************
*/
/*********************************************************************
*
*       CreateFramewin
*/
WM_HWIN CreateFramewin_Test(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万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
115778
QQ
发表于 2018-12-25 11:19:01 | 显示全部楼层
使用5.40及其以上版本里面的WIDGET_SetFocusable可以解决此问题
回复

使用道具 举报

24

主题

83

回帖

155

积分

初级会员

积分
155
 楼主| 发表于 2018-12-25 20:18:39 | 显示全部楼层
eric2013 发表于 2018-12-25 11:19
使用5.40及其以上版本里面的WIDGET_SetFocusable可以解决此问题

好的,还想问一下上面程序中函数使用方法正确吗?
回复

使用道具 举报

36

主题

2050

回帖

2158

积分

至尊会员

积分
2158
发表于 2018-12-26 10:46:39 | 显示全部楼层
手牵手看夕阳 发表于 2018-12-25 20:18
好的,还想问一下上面程序中函数使用方法正确吗?

以你实际测试为准,如果测试不行,就是不可以。
Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.
回复

使用道具 举报

24

主题

83

回帖

155

积分

初级会员

积分
155
 楼主| 发表于 2018-12-27 14:33:03 | 显示全部楼层
byccc 发表于 2018-12-26 10:46
以你实际测试为准,如果测试不行,就是不可以。

好的,谢谢你
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-17 20:20 , Processed in 0.275229 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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