|
楼主 |
发表于 2015-4-25 09:38:29
|
显示全部楼层
回 eric2013 的帖子
eric2013:我在模拟器上面测试了。没有卡死。你是在什么上面测试的。 (2015-04-24 21:13)  我是在STM32F103上用的,之前那个问题已经解决了,我把EDIT的创建顺序放在按键之前他就行了,就不会卡死了,我也不知道为什么,不过现在问题又来了,我想在已经创建好的第二个对话框里面显示EDIT的值,但是一创建就卡死了,如果不给EDIT赋值它是不会卡死的,部知道为什么,程序如下:
/*********************************************************************
* *
* 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_WINDOW_0 (GUI_ID_USER + 0x00)
#define ID_EDIT_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_0 (GUI_ID_USER + 0x02)
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x03)
#define ID_BUTTON_1 (GUI_ID_USER + 0x04)
#define ID_BUTTON_2 (GUI_ID_USER + 0x05)
#define ID_BUTTON_3 (GUI_ID_USER + 0x06)
#define ID_BUTTON_4 (GUI_ID_USER + 0x07)
#define ID_BUTTON_5 (GUI_ID_USER + 0x08)
#define ID_BUTTON_6 (GUI_ID_USER + 0x09)
#define ID_BUTTON_7 (GUI_ID_USER + 0x10)
#define ID_BUTTON_8 (GUI_ID_USER + 0x11)
#define ID_BUTTON_9 (GUI_ID_USER + 0x12)
//WM_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, "Window", ID_WINDOW_0, 24, 0, 271, 479, 0, 0x0, 0 },
{ EDIT_CreateIndirect, "Edit", GUI_ID_EDIT0, 74, 67, 80, 20, 0, 0, 0 },
{ BUTTON_CreateIndirect, "SET", ID_BUTTON_0, 95, 400, 80, 20, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
static const GUI_WIDGET_CREATE_INFO _aDialogCreate2[] = {
{ FRAMEWIN_CreateIndirect, "408", ID_FRAMEWIN_0, 50, 140, 200, 210, 0, 0x64, 0 },
{ EDIT_CreateIndirect, "Edit", GUI_ID_EDIT1, 50, 20, 80, 20, 0, 0, 0 },
{ BUTTON_CreateIndirect, "0", ID_BUTTON_1, 20, 60, 43, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "1", ID_BUTTON_2, 75, 60, 43, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "2", ID_BUTTON_3, 130, 60, 43, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "3", GUI_ID_BUTTON0, 20, 95, 43, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "4", ID_BUTTON_4, 75, 95, 43, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "5", ID_BUTTON_5, 130, 95, 43, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "6", ID_BUTTON_6, 20, 130, 43, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "7", ID_BUTTON_7, 75, 130, 43, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "8", ID_BUTTON_8, 130, 130, 43, 20, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "9", ID_BUTTON_9, 20, 165, 43, 20, 0, 0x0, 0 },
// { EDIT_CreateIndirect, "Edit", ID_EDIT_0, 50, 20, 80, 20, 0, 0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
// USER END
/*********************************************************************
*
* _cbDialog
*/
WM_HWIN hWin2;
static unsigned char i;
WM_HWIN hItem2;
static void _cbDialog2(WM_MESSAGE * pMsg) {
// static WM_HWIN hWin2;
// WM_HWIN hItem2;
// WM_HWIN hWin2;
int NCode;
int Id;
// static unsigned char i;
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
hItem2 = WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT1);
EDIT_SetDecMode(WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT1),0,0,1000,0,0);
EDIT_SetValue(WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT1),3);
//
// Initialization of 'Edit'
//
// hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT0);
// EDIT_SetText(hItem, "123");
// // 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_1: // Notifications sent by 'Button'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// GUI_EndDialog(hWin2, 0);
// i=!i;
// if(i)
// {
// // GUI_EndDialog(hDlg, 0);
// hWin2 = CreateWindow2();
//
// }
// else
// GUI_EndDialog(hWin2, 0);
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// EDIT_SetValue(WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT1),3);
// i=0;
// GUI_EndDialog(hWin2, 0);
// 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;
}
}
//WM_HWIN hDlg;
//WM_HWIN hWin;
// WM_HWIN hWin2;
// static unsigned char i;
static void _cbDialog(WM_MESSAGE * pMsg) {
// static WM_HWIN hWin2;
WM_HWIN hItem;
// WM_HWIN hWin2;
int NCode;
int Id;
// static unsigned char i;
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT0);
EDIT_SetDecMode(hItem,0,0,1000,0,0);
EDIT_SetValue(hItem,0);
// 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 GUI_ID_EDIT0: // Notifications sent by 'Edit'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
// i=!i;
// if(i)
// {
// hWin2 = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2),_cbDialog2,0, 0, 0);
// }
// else
// GUI_EndDialog(hWin2, 0);
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// i=!i;
if(!i)
{
i=1;
hWin2 = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2),_cbDialog2,0, 0, 0);
}
// else
// GUI_EndDialog(hWin2, 0);
// 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:
// GUI_EndDialog(hWin2, 0);
// i=!i;
if(i)
{
// GUI_EndDialog(hDlg, 0);
// hWin2 = CreateWindow2();
i=0;
GUI_EndDialog(hWin2, 0);
}
// else
// GUI_EndDialog(hWin2, 0);
// 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;
// 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 CreateWindow(void);
WM_HWIN CreateWindow(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
/*************************** End of file ****************************/
如果把 _cbDialog2中的
hItem2 = WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT1);
EDIT_SetDecMode(WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT1),0,0,1000,0,0);
EDIT_SetValue(WM_GetDialogItem(pMsg->hWin, GUI_ID_EDIT1),3);
这几句屏蔽掉就不会卡死的,版主能帮我看一下吗? |
|