📄 subject_36005.htm
字号:
<p>
序号:36005 发表者:玲儿响叮当 发表日期:2003-04-11 10:57:00
<br>主题:如何控制CFormView的滚动条出现?
<br>内容:我用CFormView作为一个对话框程序的子对话框,但是发现滚动条出现仅当子对话框大小小于资源中设定的CFormView的对话框的大小,这是为什么?有没有办法不修改资源改变对话框的大小?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:爱丽思 回复日期:2003-04-11 11:08:05
<br>内容:设置WS_HSCROLL和WS_VSCROLL的style<BR>再调用SetScrollSizes<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:玲儿响叮当 回复日期:2003-04-11 11:21:27
<br>内容:不明白,能否详细些?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:爱丽思 回复日期:2003-04-11 11:29:28
<br>内容:CWnd::PreCreateWindow<BR>virtual BOOL PreCreateWindow( CREATESTRUCT& cs );<BR><BR>Return Value<BR><BR>Nonzero if the window creation should continue; 0 to indicate creation failure.<BR><BR>Parameters<BR><BR>cs<BR><BR>A CREATESTRUCT structure.<BR><BR>Remarks<BR><BR>Called by the framework before the creation of the Windows window attached to this CWnd object.<BR><BR>Never call this function directly.<BR><BR>The default implementation of this function checks for a NULL window class name and substitutes an appropriate default. Override this member function to modify the CREATESTRUCT structure before the window is created. <BR><BR>Each class derived from CWnd adds its own functionality to its override of PreCreateWindow. By design, these derivations of PreCreateWindow are not documented. To determine the styles appropriate to each class and the interdependencies between the styles, you can examine the MFC source code for your application’s base class. If you choose to override PreCreateWindow, you can determine whether the styles used in your application’s base class provide the functionality you need by using information gathered from the MFC source code.<BR><BR>For more information on changing window styles, see theChanging the Styles of a Window Created by MFC in Visual C++ Programmer’s Guide.<BR><BR>CScrollView::SetScrollSizes <BR>void SetScrollSizes( int nMapMode, SIZE sizeTotal, const SIZE& sizePage = sizeDefault, const SIZE& sizeLine = sizeDefault );<BR><BR>Parameters<BR><BR>nMapMode<BR><BR>The mapping mode to set for this view. Possible values include:<BR><BR>Mapping Mode Logical Unit Positive y-axis Extends... <BR>MM_TEXT 1 pixel Downward <BR>MM_HIMETRIC 0.01 mm Upward <BR>MM_TWIPS 1/1440 in Upward <BR>MM_HIENGLISH 0.001 in Upward <BR>MM_LOMETRIC 0.1 mm Upward <BR>MM_LOENGLISH 0.01 in Upward <BR><BR><BR>All of these modes are defined by Windows. Two standard mapping modes, MM_ISOTROPIC and MM_ANISOTROPIC, are not used for CScrollView. The class library provides the SetScaleToFitSize member function for scaling the view to window size. Column three in the table above describes the coordinate orientation.<BR><BR>sizeTotal<BR><BR>The total size of the scroll view. The cx member contains the horizontal extent. The cy member contains the vertical extent. Sizes are in logical units. Both cx and cy must be greater than or equal to 0.<BR><BR>sizePage<BR><BR>The horizontal and vertical amounts to scroll in each direction in response to a mouse click in a scroll-bar shaft. The cx member contains the horizontal amount. The cy member contains the vertical amount.<BR><BR>sizeLine<BR><BR>The horizontal and vertical amounts to scroll in each direction in response to a mouse click in a scroll arrow. The cx member contains the horizontal amount. The cy member contains the vertical amount.<BR><BR>Remarks<BR><BR>Call SetScrollSizes when the view is about to be updated. Call it in your override of the OnUpdate member function to adjust scrolling characteristics when, for example, the document is initially displayed or when it changes size.<BR><BR>You will typically obtain size information from the view’s associated document by calling a document member function, perhaps called GetMyDocSize, that you supply with your derived document class. The following code shows this approach:<BR><BR>SetScrollSizes( nMapMode, GetDocument( )->GetMyDocSize( ) );<BR><BR>Alternatively, you might sometimes need to set a fixed size, as in the following code:<BR><BR>SetScrollSizes( nMapMode, CSize(100, 100) );<BR><BR>You must set the mapping mode to any of the Windows mapping modes except MM_ISOTROPIC or MM_ANISOTROPIC. If you want to use an unconstrained mapping mode, call the SetScaleToFitSize member function instead of SetScrollSizes.<BR><BR>Example<BR><BR>void CScaleView::OnUpdate( )<BR>{<BR> // ...<BR> // Implement a GetDocSize( ) member function in <BR> // your document class; it returns a CSize.<BR> SetScrollSizes( MM_LOENGLISH, GetDocument( )->GetDocSize( ) );<BR> ResizeParentToFit( ); // Default bShrinkOnly argument<BR> // ...<BR>}<BR><BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -