CWnd::OnCreate函数从未被调用
CWnd::OnCreate function never get called
概述:
我有两个实用程序,它们都有相同的通用界面,即打开一个对话框"请求用户名">
"请求用户名"的代码是在不同的库中编写的,这两个实用程序都调用该库。
问题:
在1个实用程序中,它工作得很好,我得到了这个对话框,它请求用户名,但在其他实用程序中它没有出现。
我的调查:在更深入的调查中,我发现这两个实用程序都调用CDialog::DoModal((,后者反过来调用onCreate((。在我的另一个实用程序中,断点从未命中Create函数。知道为什么吗?
样本代码
// IN actual Utility
//somewhere in code
Dialog_for_common_interface dlg( message.c_str(), "Please enter username:" );
CString username;
bool is_correct = ( dlg.DoModal(username) == IDOK )
// IN Dialog_for_common_interface
int Dialog_for_common_interface::DoModal ( CString &_reply_c )
{
int result_i = CDialog::DoModal(); // break point hits this but value of result_i = -1;
if ( result_i == IDOK )
{
_reply_c = reply_c;
}
return result_i;
}
// Breakpoint nver hits the below function
int Dialog_for_common_interface::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
SetWindowText( title_c );
return 0;
}
将对话框资源复制到两个exe项目中。并确保它们对对话框资源使用相同的ID值。
相关文章:
- 如何用参数值调用函数(仅在运行时已知)
- 从python中调用C++函数并获取返回值
- 当使用通配符和null指针调用函数时,对输出的说明
- 从R调用C++函数并对其进行集成时出错
- 使用QTreeView,如何通过调用函数只突出显示特定的行/列
- 如何在qt中从另一个类调用函数
- 在 COUT 语句中使用 COUT 调用函数
- 如何从线程中的不同模块调用函数?
- C++从函数指针数组调用函数
- 当 A 在 for 循环中调用函数 B 时,如何计算函数 A 的空间复杂度?
- 如何在 C/C++ 中从外部库调用函数
- 如何使用运算符在同一行中多次调用函数
- 是否可以创建一个从不同类调用函数的线程?
- 无法为类成员调用函数
- 如何从另一个标头 c++ 调用函数
- C++有什么方法可以在既不调用函数模板也不提供其模板参数的情况下引用函数模板?
- 如何只允许在调用函数 B 后调用函数 A?
- 我可以这样调用函数吗?
- 如何在 c++ 的类中递归调用函数方法?
- 为什么在指向对象的迭代器上调用函数不允许我更改对象本身?