In MFC 4.0, the old mechanism still works ? parent windows can handle notification messages. In addition, however, MFC 4.0 facilitates reuse by providing a feature called "message reflection" that allows these notification messages to be handled in either the child control window or the parent window, or in both.

3. 서브클리싱, 가상함수의 개념만 있다면 쉽게 이해 할 수 있다. 자식이 부모가 요청한 작업을 한다.

Windows controls frequently send notification messages to their parent windows. For instance, many controls send a control color notification message (WM_CTLCOLOR or one of its variants) to their parent to allow the parent to supply a brush for painting the background of the control.

//--------------------------------------------- theDC->SetStretchBltMode(STRETCH_DELETESCANS); //--------------------------------------------- // now blast it to the CDC passed in. // lines returns the number of lines actually displayed

BOOL CCommtestApp::InitInstance(){ // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need.

#ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif

//------------------------------------------------------char 8int 16short 16long 32float 32double 64//-----------------------------------------------------UINT-unsigned intBYTE -unsigned charLPSTR -char(LPSTR) char*LPTSTR -unsigned shortLPCTSTR -CString//--------------------------BOOL A Boolean value.BSTR A 32-bit character pointer.BYTE An 8-bit integer that is not signed.COLORREF A 32-bit value used as a color value.DWORD A 32-bit unsigned integer or the address of a segment and its associated offset.LONG A 32-bit signed integer.LPARAM A 32-bit value passed as a parameter to a window procedure or callback function.LPCSTR A 32-bit pointer to a constant character string.LPSTR A 32-bit pointer to a character string.LPCTSTR A 32-bit pointer to a constant character string that is portable for Unicode and DBCS.LPTSTR A 32-bit pointer to a character string that is portable for Unicode and DBCS.LPVOID A 32-bit pointer to an unspecified type.LRESULT A 32-bit value returned from a window procedure or callback functionUINT A 16-bit unsigned integer on Windows versions 3.0 and 3.1; a 32-bit unsigned integer on Win32.WNDPROC A 32-bit pointer to a window procedure.WORD A 16-bit unsigned integer.WPARAM A value passed as a parameter to a window procedure or callback function: 16 bits on Windows versions 3.0 and 3.1; 32 bits on Win32. Data types unique to the Microsoft Foundation Class Library include the following: POSITION A value used to denote the position of an element in a collection; used by MFC collection classes.LPCRECT A 32-bit pointer to a constant (nonmodifiable) RECT structure.

//-------------------------------------------------------------------BOOL RoundRect(int x1, int y1, int x2, int y2, int x3, int y3);BOOL RoundRect(PCRECT lpRect, POINT point);When this member function executes, the rectangle is drawn from the (x1, y1) to the (x2, y2) points. The corners are rounded by an ellipse whose width would be x3 and the ellipse's height would be x3. //-------------------------------------------------------------------BOOL Pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);BOOL Pie(LPCRECT lpRect, POINT ptStart, POINT ptEnd);The (x1, y1) point determines the upper-left corner of the rectangle in which the ellipse that represents the pie fits. The (x2, y2) point is the bottom-right corner of the rectangle. These two points can also be combined in a RECT or a CRect variable and passed as the lpRect value.

The (x3, y3) point, that can also supplied as a POINT or CPoint for lpStart argument, specifies the starting corner of the pie in a default counterclockwise direction.

The (x4, y4) point, or ptEnd argument, species the end point of the pie.

To complete the pie, a line is drawn from (x3, y3) to the center and from the center to the (x4, y4) points.//-------------------------------------------------------------------

To draw an arc, you can use the CDC::Arc() method whose syntax is:

BOOL Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);Besides the left (x1, y1) and the right (x2, y2) borders of the rectangle in which the arc would fit, an arc must specify where it starts and where it ends. These additional points are set as the (x3, y3) and (x4, y4) points of the figure. Based on this, the above arc can be illustrated as follows://-------------------------------------------------------------------This method uses the same arguments as Arc(). The difference is that while Arc() starts drawing at (x3, y3), ArcTo() does not inherently control the drawing starting point. It refers to the current point, exactly like the LineTo() (and the PolylineTo()) method. Therefore, if you want to specify where the drawing should start, can call CDC::MoveTo() before ArcTo(). Here is an example:

//------------------------------------------------------------------------You may wonder why the arc is drawn to the right side of a vertical line that would cross the center of the ellipse instead of the left. This is because the drawing of an arc is performed from right to left or from bottom to up, in the opposite direction of the clock. This is known as the counterclockwise direction. To control this orientation, the CDC class is equipped with the SetArcDirection() method. Its syntax is:

int SetArcDirection(int nArcDirection);This method specifies the direction the Arc() method should follow from the starting to the end points. The argument passed as nArcDirection controls this orientation. It can have the following values:

The default value of the direction is AD_COUNTERCLOCKWISE. Therefore, this would be used if you do not specify a direction. Here is an example that uses the same values as above with a different orientation:

BOOL AngleArc(int x, int y, int nRadius, float fStartAngle, float fSweepAngle);This member function draws a line and an arc connected. The arc is based on a circle and not an ellipse. This implies that the arc fits inside a square and not a rectangle. The circle that would be the base of the arc is defined by its center located at C(x, y) with a radius of nRadius. The arc starts at an angle of fStartAngle. The angle is based on the x axis and must be positive. That is, it must range from 0° to 360°. If you want to specify an angle that is below the x axis, such as -15°, use 360º-15°=345°. The last argument, fSweepAngle, is the angular area covered by the arc.

The AngleArc() method does not control where it starts drawing. This means that it starts at the origin, unless a previous call to MoveTo() specified the beginning of the drawing.