我现在是在用UC/GUI,其中背景建立了一个用户信息界面,这个界面上有两个子对话框,一个是软键盘对话框,另外一个是具有两个EDIT控件的输入框,现在是想在软键盘对话框的回调函数中调用另一个对话框的一个EDIT控件,然后把软键盘的按钮对应的输入到EDIT控件中,但是如何获得他的句柄呢??可不可以在不同的对话框中互相调用控件句柄呢???!求好心人解答!下面是我的程序。hItem = WM_GetDialogItem(_hDialogHZWindow, GUI_ID_EDIT2)利用这个函数貌似不对啊?
static const GUI_WIDGET_CREATE_INFO _aDialogKeyBoardHZWindow[] =
{//汉字选择框
{ WINDOW_CreateIndirect, "", 0, 0, 0, 240, 20,0},
{ EDIT_CreateIndirect, "", GUI_ID_EDIT1, 0, 0, 80, 20},
{ EDIT_CreateIndirect, "", GUI_ID_EDIT2, 80, 0, 160, 20}
};
/*********************************************************************
* 汉字
*********************************************************************/
static void _cbDialogKeyBoardHZWindow(WM_MESSAGE * pMsg)
{
int i;
WM_HWIN hDlg,hItem;
hDlg = pMsg->hWin;
hItem = WM_GetFocussedWindow();
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_LIGHTGRAY);
GUI_Clear();
break;
case WM_INIT_DIALOG:
//hItem = WM_GetDialogItem(hDlg,ID_HZINPUT);
//hItem = WM_GetFirstChild(hDlg);
//FRAMEWIN_SetTitleVis(hItem, 0);
// FRAMEWIN_SetBorderSize(hItem, 0);
//FRAMEWIN_SetBarColor(hItem, 1,GUI_LIGHTBLUE);
//FRAMEWIN_SetClientColor(hItem,GUI_LIGHTGRAY);
hItem = WM_GetDialogItem(hDlg,GUI_ID_EDIT1);
EDIT_SetFont(hItem,&GUI_Font13_ASCII);
//BUTTON_SetFocussable(hItem,0);//禁止键盘焦点
hItem = WM_GetDialogItem(hDlg,GUI_ID_EDIT2);
EDIT_SetFont(hItem,&GUI_FontHZ12);
//BUTTON_SetFocussable(hItem,0);//禁止键盘焦点
WM_SetFocus(hItem);
break;
default:
WM_DefaultProc(pMsg);
}
}
/***********************************************************
**创建窗口
************************************************************/
static WM_HWIN GUI_CreateDialogKeyboardHZWindow(WM_HWIN hParent,int x0, int y0)
{
WM_HWIN ret_win;
ret_win = GUI_CreateDialogBox(_aDialogKeyBoardHZWindow,GUI_COUNTOF(_aDialogKeyBoardHZWindow),_cbDialogKeyBoardHZWindow, hParent,x0, y0);
return ret_win;
}
/*********************************************************************
* 软键盘界面
*********************************************************************/
static const GUI_WIDGET_CREATE_INFO _aDialogKeyBoardWindow[] = {
{ WINDOW_CreateIndirect, "", 0, 0, 0, 240, 100, 0},
// { EDIT_CreateIndirect, "", GUI_ID_TEXT1, 0, 0, 80, 20},
// { EDIT_CreateIndirect, "", GUI_ID_TEXT2, 80, 0, 160, 20},
{ BUTTON_CreateIndirect, "1", BUTTON_ID_1, 0, 0, 20, 20},
{ BUTTON_CreateIndirect, "2", BUTTON_ID_2, 20, 0, 20, 20},
{ BUTTON_CreateIndirect, "3", BUTTON_ID_3, 40, 0, 20, 20},
{ BUTTON_CreateIndirect, "4", BUTTON_ID_4, 60, 0, 20, 20},
{ BUTTON_CreateIndirect, "5", BUTTON_ID_5, 80, 0, 20, 20},
{ BUTTON_CreateIndirect, "6", BUTTON_ID_6, 100, 0, 20, 20},
{ BUTTON_CreateIndirect, "7", BUTTON_ID_7, 120, 0, 20, 20},
{ BUTTON_CreateIndirect, "8", BUTTON_ID_8, 140, 0, 20, 20},
{ BUTTON_CreateIndirect, "9", BUTTON_ID_9, 160, 0, 20, 20},
{ BUTTON_CreateIndirect, "0", BUTTON_ID_0, 180, 0, 20, 20},
{ BUTTON_CreateIndirect, "Del", BUTTON_ID_BACKSPACE,200, 0, 40, 20},
{ BUTTON_CreateIndirect, "Q", BUTTON_ID_Q, 10, 20, 20, 20},
{ BUTTON_CreateIndirect, "W", BUTTON_ID_W, 30, 20, 20, 20},
{ BUTTON_CreateIndirect, "E", BUTTON_ID_E, 50, 20, 20, 20},
{ BUTTON_CreateIndirect, "R", BUTTON_ID_R, 70, 20, 20, 20},
{ BUTTON_CreateIndirect, "T", BUTTON_ID_T, 90, 20, 20, 20},
{ BUTTON_CreateIndirect, "Y", BUTTON_ID_Y, 110, 20, 20, 20},
{ BUTTON_CreateIndirect, "U", BUTTON_ID_U, 130, 20, 20, 20},
{ BUTTON_CreateIndirect, "I", BUTTON_ID_I, 150, 20, 20, 20},
{ BUTTON_CreateIndirect, "O", BUTTON_ID_O, 170, 20, 20, 20},
{ BUTTON_CreateIndirect, "P", BUTTON_ID_P, 190, 20, 20, 20},
{ BUTTON_CreateIndirect, "Caps", BUTTON_ID_CAPS, 210, 20, 30, 20},
{ BUTTON_CreateIndirect, "A", BUTTON_ID_A, 20, 40, 20, 20},
{ BUTTON_CreateIndirect, "S", BUTTON_ID_S, 40, 40, 20, 20},
{ BUTTON_CreateIndirect, "D", BUTTON_ID_D, 60, 40, 20, 20},
{ BUTTON_CreateIndirect, "F", BUTTON_ID_F, 80, 40, 20, 20},
{ BUTTON_CreateIndirect, "G", BUTTON_ID_G, 100, 40, 20, 20},
{ BUTTON_CreateIndirect, "H", BUTTON_ID_H, 120, 40, 20, 20},
{ BUTTON_CreateIndirect, "J", BUTTON_ID_J, 140, 40, 20, 20},
{ BUTTON_CreateIndirect, "K", BUTTON_ID_K, 160, 40, 20, 20},
{ BUTTON_CreateIndirect, "L", BUTTON_ID_L, 180, 40, 20, 20},
{ BUTTON_CreateIndirect, "\\", BUTTON_ID_SLASH, 200, 40, 20, 20},//\&/
//{ BUTTON_CreateIndirect, "Up", BUTTON_ID_UP, 190, 40, 40, 20},
{ BUTTON_CreateIndirect, "Z", BUTTON_ID_Z, 30, 60, 20, 20},
{ BUTTON_CreateIndirect, "X", BUTTON_ID_X, 50, 60, 20, 20},
{ BUTTON_CreateIndirect, "C", BUTTON_ID_C, 70, 60, 20, 20},
{ BUTTON_CreateIndirect, "V", BUTTON_ID_V, 90, 60, 20, 20},
{ BUTTON_CreateIndirect, "B", BUTTON_ID_B, 110, 60, 20, 20},
{ BUTTON_CreateIndirect, "N", BUTTON_ID_N, 130, 60, 20, 20},
{ BUTTON_CreateIndirect, "M", BUTTON_ID_M, 150, 60, 20, 20},
{ BUTTON_CreateIndirect, "-", BUTTON_ID_DASH, 170, 60, 20, 20},//破折号&下划线
{ BUTTON_CreateIndirect, ".", BUTTON_ID_POINT, 190, 60, 20, 20},//.&:
{ BUTTON_CreateIndirect, "英", BUTTON_ID_ENGORCHN, 210, 60, 20, 20},//.&:
//{ BUTTON_CreateIndirect, "Down", BUTTON_ID_DOWN, 200, 60, 40, 20},
//{ BUTTON_CreateIndirect, "↑", BUTTON_ID_UP, 234, 190, 20, 20},
//{ BUTTON_CreateIndirect, "↓", BUTTON_ID_DOWN, 259, 190, 20, 20},
{ BUTTON_CreateIndirect, "ESC", GUI_ID_CANCEL, 0, 80, 50, 20},
{ BUTTON_CreateIndirect, "Space", BUTTON_ID_SPACE, 50, 80, 140, 20},
{ BUTTON_CreateIndirect, "Enter", GUI_ID_OK, 190, 80, 50, 20}
};
/*********************************************************************
* 软键盘处理
*********************************************************************/
static void _cbDialogKeyBoardWindow(WM_MESSAGE * pMsg)
{
int Id,NCode,i,IdEdit;
WM_HWIN hDlg, hItem,hEdit1,hEdit2;
static WM_HWIN hEdit;
static int capslock = 0;//大小写锁定,0小写,1大写
static int engorchn = 0;//0-eng,1-chn
hEdit = WM_GetFocussedWindow();
IdEdit = WM_GetId(hEdit);
hDlg = pMsg->hWin;
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_LIGHTGRAY);
GUI_Clear();
break;
case WM_INIT_DIALOG:
//WM_MakeModal(hDlg);
//hItem = WM_GetDialogItem(hDlg,GUI_ID_GRAPH0);
//FRAMEWIN_SetTitleHeight(hItem,0);//无标题
//FRAMEWIN_SetTitleVis(hItem,0);//无标题
//FRAMEWIN_SetMoveable(hItem,1);
//WM_SetMoveable
// hItem = WM_GetDialogItem(hDlg,BUTTON_ID_KEYBOARD);
//BUTTON_SetBitmap(hItem,BUTTON_BI_UNPRESSED,&bmKeyBoard);
// BUTTON_SetBitmap(hItem,BUTTON_BI_PRESSED,&bmKeyBoard);
//BUTTON_SetBitmap(hItem,BUTTON_BI_DISABLED,&bmKeyBoard);
WM_SetStayOnTop(hDlg,1);
for(Id=BUTTON_ID_0;Id<=BUTTON_ID_SLASH;Id++)
{
hItem = WM_GetDialogItem(hDlg,Id);
BUTTON_SetFont(hItem,&GUI_Font16B_1);
BUTTON_SetTextAlign(hItem,GUI_TA_HCENTER|GUI_TA_VCENTER);
BUTTON_SetFocussable(hItem,0);//禁止键盘焦点
}
hItem = WM_GetDialogItem(hDlg,BUTTON_ID_ENGORCHN);//中英文
BUTTON_SetFont(hItem,&GUI_FontHZ_Song_16);
BUTTON_SetFocussable(hItem,0);//禁止键盘焦点
hItem = WM_GetDialogItem(hDlg,GUI_ID_TEXT1);//pinyin
TEXT_SetFont(hItem,&GUI_Font13_ASCII);
WM_HideWindow(hItem);
hItem = WM_GetDialogItem(hDlg,GUI_ID_TEXT2);//汉字
TEXT_SetFont(hItem,&GUI_FontHZ_Song_16);
WM_HideWindow(hItem);
hItem = WM_GetDialogItem(hDlg,GUI_ID_OK);
BUTTON_SetFont(hItem,&GUI_Font16B_1);
BUTTON_SetTextAlign(hItem,GUI_TA_HCENTER|GUI_TA_VCENTER);
BUTTON_SetFocussable(hItem,0);//禁止键盘焦点
hItem = WM_GetDialogItem(hDlg,GUI_ID_CANCEL);
BUTTON_SetFont(hItem,&GUI_Font16B_1);
BUTTON_SetTextAlign(hItem,GUI_TA_HCENTER|GUI_TA_VCENTER);
BUTTON_SetFocussable(hItem,0);//禁止键盘焦点
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v; /* Notification code */
switch (NCode)
{
case WM_NOTIFICATION_RELEASED: /* React only if released */
switch (Id)
{
case BUTTON_ID_ENGORCHN:
if(engorchn)//当前在中文状态
{
engorchn = 0;//按一下键则变化输入状态
hItem = WM_GetDialogItem(hDlg,BUTTON_ID_ENGORCHN);//中英文
BUTTON_SetText(hItem,"英");
WM_SetStayOnTop(_hDialogHZWindow,0);
GUI_EndDialog(_hDialogHZWindow,0);
WM_SetFocus(hEdit);
}
else//当前在英文状态
{
engorchn = 1;//按一下键则变化输入状态
hItem = WM_GetDialogItem(hDlg,BUTTON_ID_ENGORCHN);//中英文
BUTTON_SetText(hItem,"中");
_hDialogHZWindow = GUI_CreateDialogKeyboardHZWindow(_hDialogSubSysUserInforWindow,40, 120);
WM_SetStayOnTop(_hDialogHZWindow,1);
WM_SetFocus(hEdit);
}
break;
case BUTTON_ID_CAPS:
if(capslock == 0)
capslock = 1;
else capslock = 0;
break;
case BUTTON_ID_SLASH:
if(capslock==0)
EDIT_AddKey(hEdit,0x5C);//'\\'
else
EDIT_AddKey(hEdit,0x2F);//'/'
break;
case BUTTON_ID_BACKSPACE:
EDIT_AddKey(hEdit,GUI_KEY_BACKSPACE);//backspace0x08
break;
case BUTTON_ID_SPACE:
EDIT_AddKey(hEdit, 0x20);//space
break;
case BUTTON_ID_DASH:
if(capslock==1)
EDIT_AddKey(hEdit,0x5F);//'_'
else//if(capslock==0)
EDIT_AddKey(hEdit,0x2D);//'-'
break;
case BUTTON_ID_POINT:
if(capslock==0)
EDIT_AddKey(hEdit,0x2E);//'.'
else
EDIT_AddKey(hEdit,0x3A);//':'
break;
case BUTTON_ID_0:
case BUTTON_ID_1:
case BUTTON_ID_2:
case BUTTON_ID_3:
case BUTTON_ID_4:
case BUTTON_ID_5:
case BUTTON_ID_6:
case BUTTON_ID_7:
case BUTTON_ID_8:
case BUTTON_ID_9:
/* Add key to edit widget */
EDIT_AddKey(hEdit, '0' + Id - BUTTON_ID_0);
break;
case BUTTON_ID_A:
case BUTTON_ID_B:
case BUTTON_ID_C:
case BUTTON_ID_D:
case BUTTON_ID_E:
case BUTTON_ID_F:
case BUTTON_ID_G:
case BUTTON_ID_H:
case BUTTON_ID_I:
case BUTTON_ID_J:
case BUTTON_ID_K:
case BUTTON_ID_L:
case BUTTON_ID_M:
case BUTTON_ID_N:
case BUTTON_ID_O:
case BUTTON_ID_P:
case BUTTON_ID_Q:
case BUTTON_ID_R:
case BUTTON_ID_S:
case BUTTON_ID_T:
case BUTTON_ID_U:
case BUTTON_ID_V:
case BUTTON_ID_X:
case BUTTON_ID_W:
case BUTTON_ID_Y:
case BUTTON_ID_Z:
/* Add key to edit widget */
if(capslock == 1)
EDIT_AddKey(hEdit,'A'+Id-BUTTON_ID_A-20);//大写
if(capslock == 0)
EDIT_AddKey(hEdit,'a'+Id-BUTTON_ID_A-20);//小写
break;
if(engorchn)//当前在中文状态
{
if (IdEdit)
{
// Add key to edit widget
EDIT_AddKey(hEdit, 'a' + Id - BUTTON_ID_A-20);
EDIT_GetText(hEdit, text2, 7);
for(i = 0; i < 400; i++)
{
if(0 == StrCmp(text2, (char *)Param_Text_Title[i]))
break;
}
if(i > 399)
{
hItem = WM_GetDialogItem(_hDialogHZWindow, GUI_ID_EDIT2);
EDIT_SetText(hItem, " ");
}
// PYNotLen=0;
else
{
hItem = WM_GetDialogItem(_hDialogHZWindow, GUI_ID_EDIT2);
EDIT_SetText(hItem, (char *)Param[i]);
HZPos = (char *)Param[i];
jilu=i;
}
}
}
// case BUTTON_ID_KEYBOARD://KeyBoard
case GUI_ID_OK://Enter
WM_SetStayOnTop(hDlg,0);
if(engorchn)//在中文状态退出,删掉汉字选择框
GUI_EndDialog(_hDialogHZWindow,0);
GUI_EndDialog(hDlg,1);
//WM_EnableWindow(hDlg,BUTTON_ID_KEYBOARD);
//WM_SetFocus(hEdit);
break;
case GUI_ID_CANCEL://ESC
WM_SetStayOnTop(hDlg,0);
if(engorchn)//在中文状态退出,删掉汉字选择框
GUI_EndDialog(_hDialogHZWindow,0);
GUI_EndDialog(hDlg,0);
//EDIT_SetText(hEdit,(char*)0);//清空数据
//WM_SetFocus(hEdit);
//WM_EnableWindow(hDlg,BUTTON_ID_KEYBOARD);
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
}
}
/***********************************************************
**创建窗口
************************************************************/
WM_HWIN GUI_CreateDialogKeyboardWindow(WM_HWIN hParent,int x0, int y0)
{
WM_HWIN ret_win;
ret_win = GUI_CreateDialogBox(_aDialogKeyBoardWindow,GUI_COUNTOF(_aDialogKeyBoardWindow),_cbDialogKeyBoardWindow, hParent,x0, y0);
return ret_win;
} |