应该在
CReport mydlg;
char *pbuf="dflejf";mydlg.Create();
~~~~~~~~~~~~~~~
mydlg.m_myedit.SetWindowText(pbuf);
      ~~~~~~~~~~~~~~~~~~~~~~~
应该是可以吧,可是编译通过,运行就会出错了
谢谢指教没有HWND怎么去SetWindowText??

解决方案 »

  1.   

    谢谢,我试试吧没有HWND怎么去SetWindowText是什么意思?
    再请指教了
      

  2.   

    SetWindowText作用是设置窗口的标题文本,要求窗口先被创建出来,你的代码之所以出错
    是因为窗口还没有被创建!
      

  3.   

    可是m_myedit是与文本框控件联系的呀,也要先创建吗?
    如果在本身类的OnInitDialog()中用SetWindowText就不会出错了
    这是一回事吗?
    请指教,谢谢
      

  4.   

    mydlg.Create(IDD_MYEDIT,this);
    之后,还会出错,可是如果忽略了,就会出现想要的结果了
    为什么呢?CWnd* pWnd=mydlg.GetSafeWnd(); 
    是什么意思呢?有什么用呢?请指教,谢谢。
      

  5.   

    CWnd* pWnd=mydlg.GetSafeWnd(); ???????HWND GetSafeHwnd( ) const;!!!!!!
      

  6.   

    Relationship Between a C++ Window Object and an HWNDThe window object is an object of the C++ CWnd class (or a derived class) that your program creates directly. It comes and goes in response to your program’s constructor and destructor calls. The Windows window, on the other hand, is an opaque handle to an internal Windows data structure that corresponds to a window and consumes system resources when present. A Windows window is identified by a “window handle” (HWND) and is created after the CWnd object is created by a call to the Create member function of class CWnd. The window may be destroyed either by a program call or by a user’s action. The window handle is stored in the window object’s m_hWnd member variable. The following figure shows the relationship between the C++ window object and the Windows window. Creating windows is discussed in Creating Windows. Destroying windows is discussed in Destroying Window Objects.