请帮忙一个简单的问题?

chenxx96 2004-11-22 01:30:14
在SDI的窗口(此窗口继承CEditView类)中输入的信息(字母或数字),程序中怎样获得?
很急,各位高手请帮忙!
...全文
64 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
gwinner 2004-11-23
  • 打赏
  • 举报
回复
使用HOOK, 如下面这些代码:

LRESULT FAR PASCAL
GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
LPMSG lpMsg = (LPMSG) lParam;

if ( nCode >= 0 && PM_REMOVE == wParam )
{
// Don't translate non-input events.
if ( (lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST) )
{
if (::IsDialogMessage(m_hDlgWnd, lpMsg) )
{
// The value returned from this hookproc is ignored,
// and it cannot be used to tell Windows the message has been handled.
// To avoid further processing, convert the message to WM_NULL
// before returning.
lpMsg->message = WM_NULL;
lpMsg->lParam = 0;
lpMsg->wParam = 0;
}
}
}

return CallNextHookEx(m_hDlgHook, nCode, wParam, lParam);
}


然后在OnInitDialog中加下下面一行:
m_hDlgHook = SetWindowsHookEx( WH_GETMESSAGE, GetMsgProc,
NULL, GetCurrentThreadId() );
chenxx96 2004-11-23
  • 打赏
  • 举报
回复
还是取不到任何东东啊?
handwolf 2004-11-22
  • 打赏
  • 举报
回复
那就用
GetWindowText(strText);
chenxx96 2004-11-22
  • 打赏
  • 举报
回复
to:handwolf(初学者)
编译出错!
error C2664: 'void __thiscall CWnd::GetWindowTextA(class CString &) const' : cannot convert parameter 1 from 'class CString *' to 'class CString &'
A reference that is not to 'const' cannot be bound to a non-lvalue
handwolf 2004-11-22
  • 打赏
  • 举报
回复
如果在其它地方的话,你也可以先得到视图的指针,然后用GetWindowText得到!
handwolf 2004-11-22
  • 打赏
  • 举报
回复
在视图类中的话,直接
CString strText;
GetWindowText(&strText);//strText中的就是你要的信息
gaoxcheng 2004-11-22
  • 打赏
  • 举报
回复
你可以用GetwindowText()这个函数式式。

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧