getwindowstext有关问题,大家帮帮忙啊
getwindowstext问题,大家帮帮忙啊!
写了一个处理cedit回车信息的函数,但是发现,只能处理 ID 为CEDIT1,如果我在别的编辑框内输入数据并电机回车,getwinowText就得不到数据啊~这是怎么回事?
------解决方案--------------------
if(edit_str.IsEmpty())
{
tim.GetWindowText(edit_str);
}
tim是什么。控件绑定的变量?这不是 只有一个控件吗?
------解决方案--------------------
断点过了么?资源编号匹配?
if((GetFocus()->GetDlgCtrlID())>1162&&(GetFocus()->GetDlgCtrlID())<1227)
说不定在这个判断就出问题了
------解决方案--------------------
写了一个处理cedit回车信息的函数,但是发现,只能处理 ID 为CEDIT1,如果我在别的编辑框内输入数据并电机回车,getwinowText就得不到数据啊~这是怎么回事?
- C/C++ code
BOOL CBoardDlg::PreTranslateMessage(MSG* pMsg) { //if(GetFocus()-> GetDlgCtrlID() == IDC_EDIT1) if((GetFocus()->GetDlgCtrlID())>1162&&(GetFocus()->GetDlgCtrlID())<1227) { if(pMsg-> message == WM_KEYDOWN && pMsg-> wParam == VK_RETURN) { if(edit_str.IsEmpty()) { tim.GetWindowText(edit_str); } MessageBox(edit_str,NULL,NULL); MessageBox(TEXT("get the child windows"),NULL,NULL); CCalculator_TestDlg* pWnd = (CCalculator_TestDlg*)CWnd::FindWindow(NULL,TEXT("Calculator_Test")); HWND hWnd = pWnd ->GetSafeHwnd(); if(hWnd) { //获得excel的控件信息,并处理 CWnd* MyHwnd =pWnd->GetDlgItem(ID_GRIDCTRL); if(MyHwnd) { MessageBox(TEXT("find the hwnd of the gridctrl"),NULL,NULL); HWND ChildWnd = MyHwnd->GetSafeHwnd();//获得句柄 pWnd->m_Gridctrl.SetFocusCell(1,2); //pWnd->m_Gridctrl.SetItemText(1,3,edit_str);//显示数据 pWnd->m_Gridctrl.SetItemText(1,2,"Key in"); pWnd->m_Gridctrl.Invalidate(); } } return TRUE; } } return CDialog::PreTranslateMessage(pMsg); }
------解决方案--------------------
if(edit_str.IsEmpty())
{
tim.GetWindowText(edit_str);
}
tim是什么。控件绑定的变量?这不是 只有一个控件吗?
------解决方案--------------------
断点过了么?资源编号匹配?
if((GetFocus()->GetDlgCtrlID())>1162&&(GetFocus()->GetDlgCtrlID())<1227)
说不定在这个判断就出问题了
------解决方案--------------------