返回信息流由于某些原因用不了classwizard 关联变量法,于是参考网上代码,始终报错
出错代码如下:
string str="5";
GetDlgItem(IDC_EDIT1)->SetWindowText(str);
错误见下:
error C2660: 'GetDlgItem' : function does not take 1 parameters
error C2227: left of '->SetWindowTextA' must point to class/struct/union
求指点。。。若能改成功一个大西瓜回报。。。。苦闷爬下等回复~
这是一条镜像帖。来源:北邮人论坛 / cpp / #42686同步于 2010/8/25
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
某MFC废材向众大神求救:MFC 向Edit控件赋值一直没成功...[求助
Dorisy
2010/8/25镜像同步10 回复
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
看看是不是ID号有问题
【 在 Dorisy (Doris) 的大作中提到: 】
: 由于某些原因用不了classwizard 关联变量法,于是参考网上代码,始终报错
: 出错代码如下:
: string str="5";
: ...................
【 在 gootyking 的大作中提到: 】
: 看看是不是ID号有问题
: 【 在 Dorisy (Doris) 的大作中提到: 】
: : 由于某些原因用不了classwizard 关联变量法,于是参考网上代码,始终报错
: ...................
在属性里看到的就是这一只..
【 在 wks 的大作中提到: 】
: lz是不是没有在CDialog类的成员函数中调用这个GetDlgItem成员函数?
: 另一个也叫GetDlgItem的函数是全局的,取两个参数。
: --
: ...................
我也怀疑过,于是试了下
GetDlgItem(FindWindow( "a",NULL),IDC_EDIT1)->SetWindowText("5"); 来先获得标题“a”对话框的句柄,结果竟然错误显示:
SetWindowTextA' : is not a member of 'HWND__'
于是就不死不活的卡住。。
以上囧状
搞错没有啊,GetDlgItem返回的是HWND,这就是个DWORD,去哪要什么成员变量。
LZ先看看MSDN好吧,或者找本MFC的书看看
【 在 Dorisy (Doris) 的大作中提到: 】
: 我也怀疑过,于是试了下
: GetDlgItem(FindWindow( "a",NULL),IDC_EDIT1)->SetWindowText("5"); 来先获得标题“a”对话框的句柄,结果竟然错误显示:
: SetWindowTextA' : is not a member of 'HWND__'
: ...................
MFC Library Reference
CWnd::GetDlgItem
Retrieves a pointer to the specified control or child window in a dialog box or other window.
CWnd* GetDlgItem(
int nID
) const;
void GetDlgItem(
int nID,
HWND* phWnd
) const;
Parameters
nID
Specifies the identifier of the control or child window to be retrieved.
phWnd
A pointer to a child window.
Return Value
A pointer to the given control or child window. If no control with the integer ID given by the nID parameter exists, the value is NULL.
The returned pointer may be temporary and should not be stored for later use.
Remarks
The pointer returned is usually cast to the type of control identified by nID.
Example
Visual C++ Copy Code
// uses GetDlgItem to return a pointer to a user interface control
CEdit* pBoxOne;
pBoxOne = (CEdit*)GetDlgItem(IDC_MYEDIT);
GotoDlgCtrl(pBoxOne);
【 在 FadeToBlack (拜萝卜教 | GFW NMB!) 的大作中提到: 】
: 搞错没有啊,GetDlgItem返回的是HWND,这就是个DWORD,去哪要什么成员变量。
: LZ先看看MSDN好吧,或者找本MFC的书看看