Exercises

Exercise 28.1: Viewing the OnMouseMove calls

Use a block like #ifdef BOGUS at the start and #endif at the end to temporarily comment out the CPopView::onMouseMove code inside the brackets and replace it with these three lines.

CDC *pDC = GetDC(); 
pDC->TextOut(point.x, point.y, “X”); 
ReleaseDC(pDC); 

This way you’ll see an X at each position where the mouse sends a an OnMouseMove call. Notice that if you move the mouse fast the X’s are further apart. Also notice that if you resize the window after putting the X’s in it they go away. Why is that?

The reason the three suggested lines look as they do is because you need to have a CDC object in order to call a ‘graphics’ function like TextOut. You can get a CDC from a CView using the ...

Get Software Engineering and Computer Games now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.