Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 5: The Document/View Architecture Visual C++ and MFC Fundamentals


The second argument, lpRect, is the new rectangle that will enclose the window after the
window has been moved, resized, or restored.

4.2.6 Window Moving..................................................................................


WM_MOVE: When a window has been moved, the operating system needs to update its
location. Therefore, the window sends a message called ON_WM_MOVE. Its syntax is:

afx_msg void OnMove(int x, int y);

The first argument of this message specifies the left horizontal location of the left border
of the window after the window has been moved. The second argument represents the
vertical position of the top border of the window after the window has been moved.
If you want to send this message, you should first call its implementation in the parent
class

WM_MOVING: While the user is moving a window, it (the window sends) an
ON_WM_MOVING message. Its syntax is:

afx_msg void OnMoving( UINT nSide, LPRECT lpRect );

The first argument, nSide, is the edge of the window that is being moved. It is the same
as for the ON_MOVE message.
The lpRect is the target dimension of the window that is being moved. That is, it contains
the new dimensions of the window as it is being moved.

Practical Learning: Moving a Window



  1. To see the effect of moving a window, change the file as follows:


#include <afxwin.h>

class CMainFrame : public CFrameWnd
Free download pdf