Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 15: Fundamental Controls Visual C++ and MFC Fundamentals


// Draw the ellipse
dc.Ellipse(20, 170, 140, 240);

// Set the back mode to transparent for the text
dc.SetBkMode(TRANSPARENT);
// Display indicative labels
dc.TextOut(60, 115, "Circle");
dc.TextOut(55, 250, "Ellipse");

// Dismiss the GDI objects and restore the originals
dc.SelectObject(pOldBrush);
dc.SelectObject(pOldPen);
}


  1. Test the application

  2. Close it and return to MSVC


14.2.4..The Window: Its Location and Dimensions...................................


We have reviewed various ways of specifying a control’s location and its dimensions,
eitther at design or run time. Once a window or a control has been positioned on the
screen or in its confined client area, it keeps these attributes until specified otherwise.
When dealing with a main window, such as the frame of an application, a dialog box, a
property sheet, or a wizard, the user can move it around the screen as necessary and if
possible. This is usually done by dragging the title bar.

When the user grabs the title bar of a window and starts dragging to move it, the window
sends the WM_MOVING message as we saw in Lesson 4. The WM_MOVING event
fires the OnMoving() event. This event is usually left alone as it allows the user to use an
application as regularly as possible. The syntax of the OnMoving() event is:

afx_msg void OnMoving(UINT nSide, LPRECT lpRect);

The OnMoving() event fires while the window is being moved. The nSide argument
specifies the side of window that is moving. As the window is moving, this event returns
its location and dimensions as the values of the lpRect member variables.
Free download pdf