关于MFC的 SetFocus函数问题

jinkui19930917 2016-02-27 04:46:40


这样设置焦点落在密码编辑框,可我明明设置到了用户名编辑框,什么没效果,该怎么改?
...全文
614 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinkui19930917 2016-03-16
  • 打赏
  • 举报
回复
引用 6 楼 calven_2521 的回复:
lz vc6.0?
是的
向立天 2016-03-16
  • 打赏
  • 举报
回复
代码没问题 应该是ID的问题
没睡醒的蛐蛐 2016-03-16
  • 打赏
  • 举报
回复
用F12看下IDC_EDIT_NAME和IDC_EDIT_PASS的ID号是不是相同
calven_2521 2016-02-29
  • 打赏
  • 举报
回复
lz vc6.0?
schlafenhamster 2016-02-28
  • 打赏
  • 举报
回复
"when a dialog box or message box is displayed."
schlafenhamster 2016-02-28
  • 打赏
  • 举报
回复
WM_CANCELMODE The WM_CANCELMODE message is sent to cancel certain modes, such as mouse capture. For example, the system sends this message to the active window when a dialog box or message box is displayed. Certain functions also send this message explicitly to the specified window regardless of whether it is the active window. For example, the EnableWindow function sends this message when disabling the specified window. WM_CANCELMODE Parameters This message has no parameters. Return Values If an application processes this message, it should return zero.
jinkui19930917 2016-02-27
  • 打赏
  • 举报
回复
引用 2 楼 schlafenhamster 的回复:
测试代码:

void CCancelModeDlg::OnSetfocusEdit1() 
{
	if(!FindWindow(0,"xxx"))
	{
		::MessageBox(m_Edit1.m_hWnd,"SetfocusEdit1","xxx",MB_OK);
// w.o this the cursor is 'I' anywhere ,means focus in edit1 !!!
// mouse has captured by edit1
		m_Edit1.PostMessage(WM_CANCELMODE,0,0);
	}
}

void CCancelModeDlg::OnSetfocusEdit2() 
{
	if(!FindWindow(0,"yyy"))// change : AFX_IDS_APP_TITLE="yyy" 
	{
		AfxMessageBox("SetfocusEdit2");
// w.o this the cursor is 'I' anywhere ,means focus in edit2 !!!
// mouse has captured by edit2
		m_Edit2.PostMessage(WM_CANCELMODE,0,0);
	}
}
新手表示有点深奥看不懂,能简单点吗?
schlafenhamster 2016-02-27
  • 打赏
  • 举报
回复
测试代码:

void CCancelModeDlg::OnSetfocusEdit1() 
{
	if(!FindWindow(0,"xxx"))
	{
		::MessageBox(m_Edit1.m_hWnd,"SetfocusEdit1","xxx",MB_OK);
// w.o this the cursor is 'I' anywhere ,means focus in edit1 !!!
// mouse has captured by edit1
		m_Edit1.PostMessage(WM_CANCELMODE,0,0);
	}
}

void CCancelModeDlg::OnSetfocusEdit2() 
{
	if(!FindWindow(0,"yyy"))// change : AFX_IDS_APP_TITLE="yyy" 
	{
		AfxMessageBox("SetfocusEdit2");
// w.o this the cursor is 'I' anywhere ,means focus in edit2 !!!
// mouse has captured by edit2
		m_Edit2.PostMessage(WM_CANCELMODE,0,0);
	}
}
schlafenhamster 2016-02-27
  • 打赏
  • 举报
回复
AfxMessageBox 引起的 问题, 其后 发送 WM_CANCELMODE 到 edit 试试
WINDOWS程序设计中最常用的一些消息: 2 1 窗口消息:WM_CREATE,WM_DESTROY,WM_CLOSE 2 2 键盘消息:WM_CHAR,WM_KEYDOWN,WM_KEYUP 2 3 鼠标消息:WM_MOUSEMOVE,WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBCLICK,WM_RBUTTONDOWN, WM_RBUTTONUP,WM_RBUTTONDBCLICK 2 4 另一组窗口消息:WM_MOVE , WM_SIZE , WM_PAINT 2 5 焦点消息WM_SETFOCUS,WM_KILLFOCUS 3 6 定时器消息:WM_TIMER 3 MFC、ATL和STL 3 得到网关 4 CString最全面的总结 4 CString 拷贝 & 赋值 & "引用内存块" 什么时候释放? 4 FreeExtra()的作用 5 Format(...) 与 FormatV(...) 6 LockBuffer() 与 UnlockBuffer() 6 CString 只是处理串吗? 6 AllocSysString()与SetSysString(BSTR*) 7 参数的安全检验 7 CString的异常处理 7 跨模块时的CString.即一个DLL的接口函数中的参数为CString&时,它会发生怎样的现象。 7 串操作是编程中最常用也最基本的操作之一. 8 打开对话框选择多个文件 11 用VC设计托盘图标程序 12 一、NOTIFYICONDATA结构 12 二、Shell_NotifyIcon函数 13 三、托盘图标程序设计示例 13 VC常用数据类型使用转换详解 15 一、其它数据类型转换为字符串 15 二、从其它包含字符串的变量中获取指向该字符串的指针 16 三、字符串转换为其它数据类型 16 四、其它数据类型转换到CString 16 五、BSTR、_bstr_t与CComBSTR 16 六、VARIANT 、_variant_t 与 COleVariant 17 七、其它 18

15,979

社区成员

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

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