MFC对话框小结

来源:互联网 发布:vue.js 分页插件 编辑:程序博客网 时间:2024/06/06 02:31

消息传递:

AfxGetMainWnd()->Invalidate();   //向主窗口传递消息 HWND hwnd = AfxGetMainWnd()->m_hWnd;  //获得主窗口句柄

VC++ MFC编程各种窗口句柄获取函数详解 http://liuzhigong.blog.163.com/blog/static/178272375201121052238445/
非模式对话框使用手记 http://blog.chinaunix.net/space.php?uid=11037679&do=blog&cuid=239464

文本框更新:

UpdateData() and Updatedata(TRUE) are the same.
UpdateData(TRUE) is used to copy the contents of the controls into the associated variables.
UpdateData(FALSE) is used to put the values in the variables to the associated controls.

 

模式对话框调用的销毁:

CDialog::Close() == CDialog::OnCancel() == CDialog::EndDialog(IDCANCEL)一样。

CDialog::OnOK() == CDialog::EndDialog(IDOK)

在模式对话框下,用CDialog::OnOK()或CDialog::OnCancel()以及CDialog::OnClose()关闭对话框。

参考:《模态对话框与非模态对话的几种销毁方法与区别》:http://renjwjx.blog.51cto.com/811549/191320/


MFC中添加鼠标右击事件.(VC6.0):

1.单击Project|Add to Project|Components and Controls 
2.双击Visual C++ Components目录,选择Pop_up Menu组件 
3.单击Insert,确定 
4.在Add Pop_up menu to下拉列表中选择视图类对应工程的视图类 
5.单击OK就建立了默认的右键菜单 
6.修改右键菜单为你想要的右键菜单(修改ID值来实现)