完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我建了5个EDIT小工具,定义一个数组来存储数据,最大输入字符数为4, 然后想获取框中输入的数值直接显示在背景上,但是一直显示乱码,而且输出的不止4个字符,纠结了一天,感觉快崩溃了,以下贴上部分代码:static void _bgcallback(WM_MESSAGE *pMsg)
{ WM_HWIN hwin; EDIT_Handle edit; static U8 text; int i, ID; char buffer[4]; switch (pMsg ->MsgId) { case WM_PAINT: GUI_DrawBitmapEx(&bmjoba, 0, 0, 0, 0, 2500, 1875); GUI_SetTextMode(GUI_TEXTMODE_TRANS); GUI_SetFont(&GUI_Font8x16); GUI_SetColor(GUI_BLACK); GUI_DispStringAt(name, 130, 40); GUI_DispStringAt("MEDICINE", 5, 40); GUI_DispStringAt("LIFESPAN", 5, 80); GUI_DispStringAt("POSITION", 5, 120); GUI_DispStringAt("DOSE", 5, 160); GUI_SetFont(&GUI_Font13B_1); GUI_DispStringAt("(ALTERNATIVE)", 40, 160); GUI_SetFont(&GUI_Font8x16x2x2); GUI_SetColor(GUI_MAGENTA); GUI_SetTextAlign(GUI_TA_VCENTER | GUI_TA_HCENTER); GUI_DispStringAt("RECORDING", 160, 10); if (text) { for (i = 0; i < 4; i++) { edit = WM_GetDialogItem(dialogwin, GUI_ID_EDIT1 + i); GUI_SetFont(&GUI_Font8x16); GUI_SetColor(GUI_BLACK); EDIT_GetText(edit , buffer, 4); //获取EDIT工具的文本,然后显示在背景中 GUI_DispStringAt(buffer, 130, 80 + 40*i); //感觉可能是这里有问题,但是又实在不知道到底是什么问题,哭。。 } } break; case WM_APP_SHOW_TEXT: hwin = pMsg->hWinSrc; WM_HideWin(hwin); text = 1; WM_InvalidateWindow(WM_HBKWIN); break; default:WM_DefaultProc(pMsg); break; } } static void _eidtcallback(WM_MESSAGE *pMsg) { WM_HWIN hwin; WM_MESSAGE MSG; BUTTON_Handle bbutton, ***utton; EDIT_Handle hedit1, hedit2, hedit3, hedit4, hedit5; int NCode; int Id; WM_HWIN hDlg; hDlg = pMsg->MsgId; hwin = pMsg->hWin; switch (hDlg) { case WM_PAINT: GUI_DrawBitmapEx(&bmjoba, 0, 0, 0, 0, 2500, 1875); GUI_SetTextMode(GUI_TEXTMODE_TRANS); GUI_SetFont(&GUI_Font8x16); GUI_SetColor(GUI_BLACK); GUI_DispStringAt(name, 130, 40); GUI_DispStringAt("MEDICINE", 5, 40); GUI_DispStringAt("LIFESPAN", 5, 80); GUI_DispStringAt("POSITION", 5, 120); GUI_DispStringAt("DOSE", 5, 160); GUI_SetFont(&GUI_Font13B_1); GUI_DispStringAt("(ALTERNATIVE)", 40, 160); GUI_SetFont(&GUI_Font8x16x2x2); GUI_SetColor(GUI_MAGENTA); GUI_SetTextAlign(GUI_TA_VCENTER | GUI_TA_HCENTER); GUI_DispStringAt("RECORDING", 160, 10); break; case WM_INIT_DIALOG: FRAMEWIN_SetClientColor(hwin, GUI_INVALID_COLOR); //初始化对话框和小工具 bbutton = WM_GetDialogItem(hwin , GUI_ID_NO); BUTTON_SetFont(bbutton , &GUI_Font13B_1); ***utton = WM_GetDialogItem(hwin , GUI_ID_OK); BUTTON_SetFont(***utton , &GUI_Font13B_1); hedit1 = WM_GetDialogItem(hwin, GUI_ID_EDIT1); hedit2 = WM_GetDialogItem(hwin, GUI_ID_EDIT2); hedit3 = WM_GetDialogItem(hwin, GUI_ID_EDIT3); hedit4 = WM_GetDialogItem(hwin, GUI_ID_EDIT4); hedit5 = WM_GetDialogItem(hwin, GUI_ID_EDIT5); EDIT_SetTextColor(hedit1, EDIT_CI_ENABELD, GUI_RED); EDIT_SetTextColor(hedit2, EDIT_CI_ENABELD, GUI_RED); EDIT_SetTextColor(hedit3, EDIT_CI_ENABELD, GUI_RED); EDIT_SetTextColor(hedit4, EDIT_CI_ENABELD, GUI_RED); EDIT_SetTextColor(hedit5, EDIT_CI_ENABELD, GUI_RED); EDIT_SetMaxLen(hedit1, 10); EDIT_SetMaxLen(hedit2, 10); EDIT_SetMaxLen(hedit3, 10); EDIT_SetMaxLen(hedit4, 30); EDIT_SetMaxLen(hedit5, 30); EDIT_SetText(hedit1, "eg : 2016"); EDIT_SetText(hedit2, "eg : 1"); EDIT_SetText(hedit3, "eg : 1"); EDIT_SetText(hedit4, "THE POSITION U SAVE,eg:1"); EDIT_SetText(hedit5, "REST OF THE MEDICINE,eg:10"); break; case WM_NOTIFY_PARENT: Id = WM_GetId( pMsg ->hWinSrc); NCode = pMsg->Data.v; switch (Id) { case GUI_ID_OK: //当按下OK健的时候,对话框窗口关闭 switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: MSG.MsgId = WM_APP_SHOW_TEXT; MSG.hWinSrc = pMsg->hWin; WM_SendMessage(WM_HBKWIN , &MSG); break; } break; case GUI_ID_NO: switch (NCode) { case WM_NOTIFICATION_CLICKED: break; case WM_NOTIFICATION_RELEASED: WM_HideWin(hwin); GUI_Clear(); break; } break; } break; default:WM_DefaultProc(pMsg); break; } } 最后输入的和结果显示的图片是这样的: |
|
相关推荐
2个回答
|
|
自己解决了,原来是因为创建列表的时候创建了阻塞型,改成GUI_CreateDialogBox()就可以了,此时只想打扁自己
|
|
|
|
GOOD..........
|
|
|
|
只有小组成员才能发言,加入小组>>
798 浏览 0 评论
1155 浏览 1 评论
2531 浏览 5 评论
2863 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2713 浏览 6 评论
keil5中manage run-time environment怎么是灰色,不可以操作吗?
1087浏览 3评论
195浏览 2评论
461浏览 2评论
374浏览 2评论
M0518 PWM的电压输出只有2V左右,没有3.3V是怎么回事?
456浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 12:11 , Processed in 1.079515 second(s), Total 84, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号