Created
June 19, 2013 03:00
-
-
Save InPermutation/5811394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////////////////////////// | |
// Dispatch map | |
BEGIN_DISPATCH_MAP(CCircCtrl, COleControl) | |
//{{AFX_DISPATCH_MAP(CCircCtrl) | |
DISP_PROPERTY_NOTIFY(CCircCtrl, "CircleShape", m_circleShape, OnCircleShapeChanged, VT_BOOL) | |
DISP_PROPERTY_NOTIFY(CCircCtrl, "FlashColor", m_flashColor, OnFlashColorChanged, VT_COLOR) | |
DISP_PROPERTY_EX(CCircCtrl, "CircleOffset", GetCircleOffset, SetCircleOffset, VT_I2) | |
DISP_PROPERTY_EX(CCircCtrl, "Note", GetNote, SetNote, VT_BSTR) | |
DISP_STOCKPROP_BACKCOLOR() | |
DISP_STOCKPROP_CAPTION() | |
DISP_STOCKPROP_FONT() | |
DISP_STOCKPROP_FORECOLOR() | |
//}}AFX_DISPATCH_MAP | |
DISP_FUNCTION_ID(CCircCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE) | |
END_DISPATCH_MAP() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////////////////////////// | |
// CCircCtrl::OnDraw - Drawing function | |
void CCircCtrl::OnDraw( | |
CDC* pdc, const CRect& rcBounds, const CRect&) | |
{ | |
CBrush* pOldBrush; | |
CBrush bkBrush(TranslateColor(GetBackColor())); | |
CPen* pOldPen; | |
CRect rc = rcBounds; | |
CFont* pOldFont; | |
TEXTMETRIC tm; | |
const CString& strCaption = InternalGetText(); | |
// Set the ForeColor property color and transparent background mode into the device context | |
pdc->SetTextColor(TranslateColor(GetForeColor())); | |
pdc->SetBkMode(TRANSPARENT); | |
// Paint the background using the BackColor property | |
pdc->FillRect(rcBounds, &bkBrush); | |
// Draw the ellipse using the BackColor property and a black pen | |
GetDrawRect(&rc); | |
pOldBrush = pdc->SelectObject(&bkBrush); | |
pOldPen = (CPen*)pdc->SelectStockObject(BLACK_PEN); | |
pdc->Ellipse(rc); | |
// Draw the caption and note using the stock Font and ForeColor properties | |
pOldFont = SelectStockFont(pdc); | |
GetStockTextMetrics(&tm); | |
pdc->SetTextAlign(TA_CENTER | TA_TOP); | |
pdc->ExtTextOut((rc.left + rc.right) / 2, (rc.top + rc.bottom - tm.tmHeight) / 2, | |
ETO_CLIPPED, rc, strCaption, strCaption.GetLength(), NULL); | |
pdc->SetTextAlign(TA_LEFT | TA_TOP); | |
pdc->ExtTextOut(rcBounds.left, rcBounds.top, | |
ETO_CLIPPED, rcBounds, m_note, m_note.GetLength(), NULL); | |
pdc->SelectObject(pOldFont); | |
pdc->SelectObject(pOldPen); | |
pdc->SelectObject(pOldBrush); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment