VC++编程常见问题解答三 7、如何创建一个字回绕的CEditView 重载CWnd : : PreCreateWindow和修改CREATESTRUCT结构,关闭CEditView对 象 的ES_AUTOHSCROLL和WS_HSCROLL风格位, 由于CEditView : : PreCreateWindow显示设置cs. style,调用基类函数后要修改cs . style。 BOOL CSampleEDitView : : PreCreateWindow (CREATESTRUCT&cs) { //First call basse class function . BOOL bResutl =CEditView : : PreCreateWindow (cs) ; // Now specify the new window style . cs.style &= ~ (ES_AUTOHSCROLL |WS_HSCROLL); return bResult ; } 18、通用控件的显示窗口 MFC提供了几个CView派生的视窗类, 封装了通用控件的功能,但仍然使用工 作框文档显示窗口体系结构:CEditView封装了编辑控件,CTreeView保持了树列 表控件,CListView封装了列表显示窗口控件,CRichEditView可以处理多种编辑 控件。 19、移动窗口 调用CWnd : : SetWindowPos并指定SWP_NOSIZE标志。目的位置与父窗口有关 (顶层窗口与屏幕有关)。调用CWnd : : MoveWindow时必须要指定窗口的大小。 //Move window to positoin 100 , 100 of its parent window . SetWindowPos (NULL, 100 , 100 , 0 , 0 , SWP_NOSIZE |SWP_NOAORDER); 20、重置窗口的大小 调用CWnd: : SetWindowPos并指定SWP_NOMOVE标志, 也可调用CWnd : : MoveWindow 但必须指定窗口的位置。 // Get the size of the window . Crect reWindow ; GetWindowRect (reWindow ); //Make the window twice as wide and twice as tall . SetWindowPos (NULL , 0 , 0 , reWindow . Width ( ) *2, reWindow . Height () * 2, SWP_NOMOVE |SWP_NOZORDER );