几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   vc编程 (http://www.dimcax.com/hust/forumdisplay.php?f=76)
-   -   编辑框的问题:如何设置编辑框文本? (http://www.dimcax.com/hust/showthread.php?t=901)

yogy 2007-06-02 12:50 PM

编辑框的问题:如何设置编辑框文本?
 
CWnd *trywnd=this->FindWindowEx(NULL,NULL,"#32770","try");
CWnd *edit=this->FindWindowEx(trywnd->m_hWnd,NULL,"Edit","");
if(edit->m_hWnd)
{
edit->SendMessage(WM_SETTEXT,0,(LPARAM)(LPCTSTR)("fanqing"));


}
上面代码我测试过了成功.
但是使用
edit->setwindowtext没有成功.证明了楼上的一句话SetWindowText cannot change the text of a control in another application.

yogy 2007-06-02 12:51 PM

回复: 编辑框的问题:如何设置编辑框文本?
 
MFC的SetWindowText应该和SDK的SetWindowText类似,请看SDK的SetWindowText:

The SetWindowText function changes the text of the specified window's title bar (if it has one).
If the specified window is a control, the text of the control is changed.
(注意:--->) However, SetWindowText cannot change the text of a control in another application.


所有的时间均为北京时间。 现在的时间是 06:13 PM.