Figure 2 ncm.cpp
////////////////
// NONCLIENTMETRICS 结构, 在 winuser.h 中定义
//
struct NONCLIENTMETRICS
{
    UINT    cbSize;
    int     iBorderWidth;
    int     iScrollWidth;
    int     iScrollHeight;
    int     iCaptionWidth;
    int     iCaptionHeight;
    LOGFONT lfCaptionFont;
    int     iSmCaptionWidth;
    int     iSmCaptionHeight;
    LOGFONT lfSmCaptionFont;
    int     iMenuWidth;
    int     iMenuHeight;
    LOGFONT lfMenuFont;
    LOGFONT lfStatusFont;
    LOGFONT lfMessageFont;
};

Figure 3 Region Functions
CombineRgn
CreateEllipticRgn
CreateEllipticRgnIndirect
CreatePolygonRgn
CreatePolyPolygonRgn
CreateRectRgn
CreateRectRgnIndirect
CreateRoundRectRgn
EqualRgn
ExtCreateRegion
FillRgn
FrameRgn
GetPolyFillMode
GetRegionData
GetRgnBox
InvertRgn
OffsetRgn
PaintRgn
PtInRegion
RectInRegion
SetPolyFillMode 
SetRectRgn

Figure 4 CMainFrame

MainFrm.h
////////////////
// 标准的 MFC 主框架窗口
//
class CMainFrame : public CFrameWnd {
public:
   virtual ~CMainFrame();

protected:
   CStatusBar  m_wndStatusBar;
   CToolBar    m_wndToolBar;
   CRgn        m_rgn;
   CMainFrame();
   DECLARE_DYNCREATE(CMainFrame)

   //{{AFX_MSG(CMainFrame)
   afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
   afx_msg void OnSize(UINT nType, int cx, int cy);
   //}}AFX_MSG
   DECLARE_MESSAGE_MAP()
};
MainFrm.cpp
////////////////////////////////////////////////////////////////
// VCKBASE Online Journal - October 2000. 
//
#include "StdAfx.h"
#include "NonRect.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
   //{{AFX_MSG_MAP(CMainFrame)
   ON_WM_CREATE()
   ON_WM_SIZE()
   //}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] = {
   ID_SEPARATOR,           // 状态条指示器
   ID_INDICATOR_CAPS,
   ID_INDICATOR_NUM,
   ID_INDICATOR_SCRL,
};

CMainFrame::CMainFrame()
{
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
      return -1;
   
   if (!m_wndToolBar.Create(this) ||
      !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
      TRACE0("Failed to create toolbar\n");
      return -1;      // 创建失败
   }

   if (!m_wndStatusBar.Create(this) ||
      !m_wndStatusBar.SetIndicators(indicators,
        sizeof(indicators)/sizeof(UINT))) {
      TRACE0("Failed to create status bar\n");
      return -1;      // 创建失败
   }

   // TODO: Remove this if you don't want tool tips or a resizable toolbar
   m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
      CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

   // TODO: Delete these three lines if you don't want the toolbar to
   //  be dockable
   m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
   EnableDocking(CBRS_ALIGN_ANY);
   DockControlBar(&m_wndToolBar);

   return 0;
}

//////////////////
// 改变窗口大小后,更新窗口区
//
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
   CFrameWnd::OnSize(nType, cx, cy);

   // 销毁旧区域
   m_rgn.DeleteObject();

   // 根据新的窗口大小创建圆角矩形区
   CRect rc;                  // 圆角矩形 
   GetWindowRect(&rc);        // 屏幕坐标中的矩形
   rc -= rc.TopLeft();        // 转换为窗口坐标: 左上角 = (0,0)
   m_rgn.CreateRoundRectRgn(rc.left,rc.top,rc.right,rc.bottom,
      50,50);                 // 50 pixel 角的圆角矩形
   SetWindowRgn(m_rgn,TRUE);  // 设置窗口区为圆角窗口
}