Height()/2;
int nArrowBottom = m_ArrowRect.bottom - 1 - 2*Margins.cx;
int nArrowHeight = nArrowBottom - nArrowTop + 1;
int nAdjust = (m_ArrowRect.Height() - 4*Margins.cy - nArrowHeight)/2;
CPoint p[4];
//p[0] = CPoint(m_ArrowRect.left + m_ArrowRect.Width()/2, nArrowBottom - nAdjust);
//p[1] = CPoint(m_ArrowRect.left + 2*Margins.cy, nArrowTop - nAdjust);
//p[2] = CPoint(m_ArrowRect.right - 2*Margins.cy-1, nArrowTop - nAdjust);
//p[3] = p[0];
// If you want rectangle then use following pts
// 1 2
// 4 3
p[0] = CPoint(m_ArrowRect.left+m_ArrowRect.Width()/2-CONTROL_OFFSET,
m_ArrowRect.top+m_ArrowRect.Height()/2-3*CONTROL_OFFSET/4);
p[1] = CPoint(m_ArrowRect.left+m_ArrowRect.Width()/2+CONTROL_OFFSET,
m_ArrowRect.top+m_ArrowRect.Height()/2-3*CONTROL_OFFSET/4);
p[2] = CPoint(m_ArrowRect.left+m_ArrowRect.Width()/2+CONTROL_OFFSET,
m_ArrowRect.top+m_ArrowRect.Height()/2+3*CONTROL_OFFSET/4);
p[3] = CPoint(m_ArrowRect.left+m_ArrowRect.Width()/2-CONTROL_OFFSET,
m_ArrowRect.top+m_ArrowRect.Height()/2+3*CONTROL_OFFSET/4);
pDC->SelectStockObject(BLACK_BRUSH);
pDC->SelectStockObject(BLACK_PEN);
pDC->Polygon(p, 4);
pDC->DrawEdge(rect, EDGE_SUNKEN, BF_RECT);
// Must reduce the size of the "client" area of the button due to edge thickness.
rect.DeflateRect(Margins.cx, Margins.cy);
// Fill remaining area with colour
rect.right -= m_ArrowRect.Width();
if(m_CurBitmap == 0)
{
rect.InflateRect(-2,-2);
pDC->DrawFrameControl(rect, DFC_BUTTON, DFCS_BUTTONPUSH);
pDC->DrawText(this->m_CurText, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
}
else
{
HBITMAP hBitmap =(HBITMAP) LoadImage (AfxGetInstanceHandle(),
MAKEINTRESOURCE (m_CurBitmap), IMAGE_BITMAP,
0,0,LR_DEFAULTCOLOR|LR_LOADTRANSPARENT|LR_LOADMAP3DCOLORS );
//GetClientRect (rect);
CDC memdc;
CBitmap bmp;
CBitmap *poldbmp;
bmp.Attach (hBitmap);
BITMAP bitmap;
bmp.GetBitmap (&bitmap);
memdc.CreateCompatibleDC( pDC );
// Select the bitmap into the DC
poldbmp = (CBitmap *) memdc.SelectObject( &bmp );
// Copy (BitBlt) bitmap from memory DC to screen DC
// I want it to look like a proper button hence
pDC->DrawFrameControl(rect, DFC_BUTTON, DFCS_BUTTONPUSH);
rect.InflateRect(-4,-4);
pDC -> StretchBlt( rect.left,rect.top,
rect.right-rect.left,
rect.bottom -rect.top, &memdc,0,0,
bitmap.bmWidth,bitmap.bmHeight, SRCCOPY );
//pDC -> BitBlt( rect.left,rect.top,
// rect.right-rect.left,
// rect.bottom -rect.top, &memdc,0,0,
// SRCCOPY );
memdc.SelectObject( poldbmp );
}
//pDC->FillSolidRect(rect, m_crColour);
// Draw focus rect
if (state & ODS_FOCUS)
{
rect.DeflateRect(1,1);
pDC->DrawFocusRect(rect);
}
}
/////////////////////////////////////////////////////////////////////////////
// CVxOptPicker overrides
void CVxOptPicker::PreSubclassWindow()
{
ModifyStyle(0, BS_OWNERDRAW); // Make it owner drawn
CButton::PreSubclassWindow();
SetWindowSize(); // resize appropriately
}
/////////////////////////////////////////////////////////////////////////////
// CVxOptPicker implementation
void CVxOptPicker::SetWindowSize()
{
// Get size dimensions of edges
CSize MarginSize(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE));
// Get size of dropdown arrow
int nArrowWidth = max(::GetSystemMetrics(SM_CXHTHUMB), 10*MarginSize.cx);
int nArrowHeight = max(::GetSy