CLoginDlg dlg;m_pMainWnd = &dlg;编译出错?

wulianhai 2010-01-05 02:58:57
CLoginDlg dlg;
m_pMainWnd = &dlg;


error C2501: 'm_pMainWnd' : missing storage-class or type specifiers
error C2440: 'initializing' : cannot convert from 'class CLoginDlg *' to 'int'

请各位帮我解决下。。。谢谢


m_pMainWnd 这个要初始化嘛?如果要的话,那在哪个类呢?
...全文
620 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eleven 2010-03-24
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 sullensun 的回复:]
呵呵 ,你多了个大括号,细心点。。。
[/Quote]
汗。。。。。。。。。
SullenSun 2010-03-24
  • 打赏
  • 举报
回复
呵呵 ,你多了个大括号,细心点。。。
wlc311 2010-03-24
  • 打赏
  • 举报
回复
rebuild 一下不就行了,哎
hlwbb 2010-01-07
  • 打赏
  • 举报
回复
将楼主代码复制到新项目中,发现了一些问题,多一行反大括号
catch(_com_error e)///捕捉异常
{
CString errormessage;
errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
return FALSE;
}

}// 多了这行反大括号

// 将宏定义#ifdef _AFXDLL 几行注释再定义m_pConnection,重新编译,编译通过,没出现楼主所说的问题。
hlwbb 2010-01-07
  • 打赏
  • 举报
回复
m_pMainWnd 是class CWinThread的一个成员函数,
CLoginApp是继承CWinApp,不用定义
pady_pady 2010-01-06
  • 打赏
  • 举报
回复
提示你m_pMainWnd未定义,看看头文件Cxxapp.h里面有没有定义
M_S_D_N 2010-01-06
  • 打赏
  • 举报
回复
哎,不懂装懂的人,真多。
ligeqiang 2010-01-05
  • 打赏
  • 举报
回复
有道理,支持你。

[Quote=引用 10 楼 miaolingshaohua 的回复:]
引用 9 楼 ligeqiang 的回复:
定义 m_pMainWnd 的头文件也贴出来吧。

而且下面这句也没有什么意义呀
m_pMainWnd = &dlg;

这个东东
CLoginDlg dlg;
出了InitInstance()就被干掉了啊!


你放进InitInstance里面
[/Quote]
vividand 2010-01-05
  • 打赏
  • 举报
回复
'm_pMainWnd' 定义成CWnd *m_pMainWnd或者CLoginDlg *m_pMainWnd就可以了
哈利路亚1874 2010-01-05
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 ligeqiang 的回复:]
定义 m_pMainWnd 的头文件也贴出来吧。

而且下面这句也没有什么意义呀
m_pMainWnd = &dlg;

这个东东
CLoginDlg dlg;
出了InitInstance()就被干掉了啊!

[/Quote]
你放进InitInstance里面
ligeqiang 2010-01-05
  • 打赏
  • 举报
回复
定义 m_pMainWnd 的头文件也贴出来吧。

而且下面这句也没有什么意义呀
m_pMainWnd = &dlg;

这个东东
CLoginDlg dlg;
出了InitInstance()就被干掉了啊!
zealand_1 2010-01-05
  • 打赏
  • 举报
回复
你要干什么?
cbib_cat 2010-01-05
  • 打赏
  • 举报
回复
'm_pMainWnd' 在哪里 定义的?
Ryanwen 2010-01-05
  • 打赏
  • 举报
回复
添加CLoginDlg 的头文件了吗?
shen_wei 2010-01-05
  • 打赏
  • 举报
回复
直接dlg.DoModal(); 你不就是想要一个对话框显示吗、
na_he 2010-01-05
  • 打赏
  • 举报
回复
很奇怪的哦,这应该是dialog程式自动生成的代码呀,你重新成成一个看看了。
wulianhai 2010-01-05
  • 打赏
  • 举报
回复
BOOL CLoginApp::InitInstance()
{
AfxEnableControlContainer();
AfxOleInit();///初始化COM库
////////////连接数据库//////////////
HRESULT hr;
try
{
hr = m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象
if(SUCCEEDED(hr))
{
hr=m_pConnection->Open("Driver={SQL Server};Server=172.18.25.3;Database=login;User ID=sa;PWD=","","",adModeUnknown); //创建面向SQL server的连接
//hr = m_pConnection->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb","","",adModeUnknown);///连接数据库
///上面一句中连接字串中的Provider是针对ACCESS2000环境的,对于ACCESS97,需要改为:Provider=Microsoft.Jet.OLEDB.3.51; }
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
errormessage.Format("连接数据库失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
return FALSE;
}

}


// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.

#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif

CLoginDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}

// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;

}
快乐鹦鹉 2010-01-05
  • 打赏
  • 举报
回复
大侠,你这两句话写在哪里的啊??????
sandyandy 2010-01-05
  • 打赏
  • 举报
回复
m_pMainWnd 是在哪里定义的?

15,979

社区成员

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

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