新手上路
- 积分
- 34
- 金钱
- 34
- 注册时间
- 2016-4-6
- 在线时间
- 8 小时
|
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "GUI.h"
#include "FRAMEWIN.h"
#include "MULTIPAGE.h"
#include "EDIT.H"
#include "FRAMEWIN.h"
#include "BUTTON.H"
#include "TEXT.H"
#include "RADIO.H"
#include "SLIDER.H"
#include "DROPDOWN.H"
#include "MULTIEDIT.H"
#include <stdio.h>
#include "PROGBAR.h"
#include "integer.h"
char aBuffer[4];
static const GUI_WIDGET_CREATE_INFO aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "", ID_FRAMEWIN_0, 0, 1, 800, 480, 0},
{ BUTTON_CreateIndirect, "", ID_BUTTON_16, 240, 270, 50, 40},
};
const GUI_FONT* pFont =&GUI_FontHZ_Terminal_21;
WM_HWIN hWin;
WM_HWIN hWin_key;
BUTTON_Handle _ahButton[19];
static void cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int Id, NCode;
switch (pMsg->MsgId) {
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_16:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
hWin_key=GUI_CreateDialogBox(aDialogCreate1, GUI_COUNTOF(aDialogCreate1), cbDialog1, 0, 0, 0);
WM_MakeModal(hWin_key);
WM_SetFocus(hWin_key);
while(1)
{
GUI_Exec();
GUI_TOUCH_Exec();
// GUI_Delay(1);
/*send232(aBuffer[0]);
send232(aBuffer[1]);
send232(aBuffer[2]);
send232(aBuffer[3]);*/
}
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
static void cbDialog1(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'keyword'
//
hItem = pMsg->hWin;
FRAMEWIN_SetTitleHeight(hItem, 30);
FRAMEWIN_SetFont(hItem,pFont);
FRAMEWIN_SetTextAlign(hWin, GUI_TA_HCENTER);
//
// Initialization of 'INPUT'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_9);
EDIT_SetText(hItem, "");
EDIT_SetTextColor(hItem, EDIT_CI_ENABLED, 0x000000);
EDIT_SetFont(hItem, &GUI_Font24_1);
EDIT_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
// Initialization of '1'
//
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON0);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
// Initialization of '2'
//
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON1);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
//
// Initialization of '3'
//
hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_BUTTON2);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
// Initialization of '8'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_23);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
// Initialization of '9'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_24);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
// Initialization of '4'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_19);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
// Initialization of '5'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_20);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
// Initialization of '6'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_21);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
// Initialization of '7'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_22);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
// Initialization of '0'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_25);
BUTTON_SetFont(hItem, &GUI_Font24_1);
// Initialization of '.'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_26);
BUTTON_SetFont(hItem, &GUI_Font24_1);
//
// Initialization of退格
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_27);
BUTTON_SetFont(hItem,pFont);
//
// Initialization of 确定
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_28);
BUTTON_SetFont(hItem,pFont);
//
// Initialization of 取消
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_29);
BUTTON_SetFont(hItem,pFont);
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case GUI_ID_BUTTON0: // Notifications sent by '1'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'1');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON0),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case GUI_ID_BUTTON1: // Notifications sent by '2'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'2');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON1),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case GUI_ID_BUTTON2: // Notifications sent by '3'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'3');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,GUI_ID_BUTTON2),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_19: // Notifications sent by '4'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'4');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,ID_BUTTON_19),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_20: // Notifications sent by '5'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'5');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,ID_BUTTON_20),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_21: // Notifications sent by '6'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'6');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,ID_BUTTON_21),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_22: // Notifications sent by '7'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'7');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,ID_BUTTON_22),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_23: // Notifications sent by '8'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'8');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,ID_BUTTON_23),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_24: // Notifications sent by '9'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'9');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,ID_BUTTON_24),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_25: // Notifications sent by '0'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'0');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,ID_BUTTON_25),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_26: // Notifications sent by '.'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'.');
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,ID_BUTTON_26),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_27: // Notifications sent by 退格
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_SetText(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),"");
BUTTON_SetState(WM_GetDialogItem(pMsg->hWin,ID_BUTTON_27),BUTTON_STATE_FOCUS);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_28: // Notifications sent by 确定
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
EDIT_AddKey(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),'\0');
EDIT_GetText(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),aBuffer,sizeof(aBuffer));
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_BUTTON_29: // Notifications sent by 取消
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
GUI_EndDialog(pMsg->hWin, 0);
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
void Init_Conf(void)
{ WM_SetDesktopColor(GUI_WHITE); /* Automatically update desktop window */
hWin = GUI_CreateDialogBox(aDialogCreate, GUI_COUNTOF(aDialogCreate), cbDialog, 0, 0, 0);
FRAMEWIN_SetFont(hWin, pFont);
FRAMEWIN_SetTextAlign(hWin, GUI_TA_HCENTER);
_ahButton[1] = WM_GetDialogItem(hWin, ID_BUTTON_16);
}
void run(void)
{ GUI_Init();
Init_Conf();
while(1)
{
GUI_Exec();
GUI_TOUCH_Exec();
//GUI_Delay(5);
}
}
这是一个GUI程序源码,功能是按下界面上一个按钮后,弹出一个软键盘对话框,我的问题是:无法获得软键盘中输入到TEXT控件上的值,好像函数
EDIT_GetText(WM_GetDialogItem(pMsg->hWin,ID_EDIT_9),aBuffer,sizeof(aBuffer));没有起作用一样,aBuffer[]的值一直是0,请大神帮我看看程序,找找原因。程序其他部分都是好的。 |
|