Call SetScrollSizes when the view is about to be updated. //当视图准备被更新的时候调用该函数
void SetScrollSizes( int nMapMode, SIZE sizeTotal, const SIZE& sizePage = sizeDefault, const SIZE& sizeLine = sizeDefault ); |
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.
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:
当,例如文档初始显示或者是当文档更改了大小的时候,在你覆盖的OnUpdate成员函数中调用该函数用来调整放缩特征。你通常可以从视图的关联文档通过调用一个文档的成员函数来获取尺寸信息,也许是调用GetMyDocSize,这个函数被你集成的文档类所提供。下面的代码展示了这种方法:
| Visual C++ | Copy Code |
|---|---|
CMyScrollDoc* pMyDoc = (CMyScrollDoc*)GetDocument(); SetScrollSizes(nMapMode, pMyDoc->GetMyDocSize()); | |
Alternatively, you might sometimes need to set a fixed size, as in the following code:
或者,你也许有时会需要设置一个固定的尺寸,如下面代码所示:
| Visual C++ | Copy Code |
|---|---|
SetScrollSizes(nMapMode, CSize(100, 100)); | |
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.
必须为窗口映射模式设置映射模式,影射模式排除MM_ISOTROPIC 和 MM_ANISOTROPIC。如果想要使用一个无约束的映射模式,调用SetScaleToFitSize成员函数来代替SetScrollSizes