Book Image

Microsoft Visual C++ Windows Applications by Example

By : Stefan Bjornander, Stefan Björnander
Book Image

Microsoft Visual C++ Windows Applications by Example

By: Stefan Bjornander, Stefan Björnander

Overview of this book

Table of Contents (15 chapters)
Microsoft Visual C++ Windows Applications by Example
Credits
About the Author
About the Reviewer
Preface
Index

Setting the Coordinate System and the Scroll Bars


So far, the r ings are drawn with a radius of 10 pixels, which means that we cannot define an exact radius measured in inches or meters (or at least not without research, the pixel size of every screen we execute the application on). We can address the problem by modifying OnInitialUpdate.

RingView.cpp

void CRingView::OnInitialUpdate()
{
  CScrollView::OnInitialUpdate();
  CSize sizeTotal;
  // TODO: calculate the total size of this view
  sizeTotal.cx = sizeTotal.cy = 100;
  SetScrollSizes(MM_TEXT, sizeTotal);
}

The function SetScrollSizes sets the scroll bars to reflect the chosen coordinate system. Let us chose the metric system with high resolution: MM_HIMETRIC; one logical unit is a hundredth of a millimeter. We set the page to correspond to a letter with a width of 216 millimetres and a height of 279 millimetres; we set the height of a line to 5 millimeters and the height of a page to 50 millimeters.

RingView.cpp

void CRingView::OnInitialUpdate...