// RndRcDlg.cpp : implementation file // #include "stdafx.h" #include "MagGlass.h" #include "RndRcDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CRoundRectDlg dialog CRoundRectDlg::CRoundRectDlg(CWnd* pParent /*=NULL*/) : CDialog(CRoundRectDlg::IDD, pParent) { //{{AFX_DATA_INIT(CRoundRectDlg) m_nEllipseHeight = 50; m_nEllipseWidth = 50; m_nRectHeight = 100; m_nRectWidth = 100; //}}AFX_DATA_INIT m_hRoundRectRgn = NULL; } CRoundRectDlg::~CRoundRectDlg() { if (m_hRoundRectRgn) { ::DeleteRgn(m_hRoundRectRgn); m_hRoundRectRgn = NULL; } } void CRoundRectDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CRoundRectDlg) DDX_Text(pDX, IDC_ROUNDELLIPSE_HEIGHT, m_nEllipseHeight); DDX_Text(pDX, IDC_ROUNDELLIPSE_WIDTH, m_nEllipseWidth); DDX_Text(pDX, IDC_ROUNDRECT_HEIGHT, m_nRectHeight); DDX_Text(pDX, IDC_ROUNDRECT_WIDTH, m_nRectWidth); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CRoundRectDlg, CDialog) //{{AFX_MSG_MAP(CRoundRectDlg) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CRoundRectDlg message handlers void CRoundRectDlg::OnOK() { UpdateData(TRUE); if (m_nRectWidth < 1) { AfxMessageBox("The rectangle width must be positive nonzero value!"); return; } else if (m_nRectWidth > MAX_ROUNDRECT) { AfxMessageBox("The rectangle width must be within the range!"); return; } if (m_nRectHeight < 1) { AfxMessageBox("The rectangle height must be positive nonzero value!"); return; } else if (m_nRectHeight > MAX_ROUNDRECT) { AfxMessageBox("The rectangle height must be within the range!"); return; } if (m_nEllipseWidth < 1) { AfxMessageBox("The ellipse width must be positive nonzero value!"); return; } else if (m_nEllipseWidth > MAX_ROUNDRECT) { AfxMessageBox("The ellipse width must be within the range!"); return; } if (m_nEllipseHeight < 1) { AfxMessageBox("The ellipse height must be positive nonzero value!"); return; } else if (m_nEllipseHeight > MAX_ROUNDRECT) { AfxMessageBox("The ellipse height must be within the range!"); return; } if (m_hRoundRectRgn) { ::DeleteRgn (m_hRoundRectRgn); m_hRoundRectRgn = NULL; } m_hRoundRectRgn = ::CreateRoundRectRgn(0, 0, m_nRectWidth, m_nRectHeight, m_nEllipseWidth, m_nEllipseHeight); if (!m_hRoundRectRgn) { AfxMessageBox("Error creating Magnifying Glass Round Rect shape!"); return; } CDialog::OnOK(); }