?? mtextcolorbox.cpp
字號:
// MTextColorBox.cpp : implementation file
//
#include "stdafx.h"
#include "MTextColorBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "stylebar.h"
/////////////////////////////////////////////////////////////////////////////
// CMTextColorBox
CMTextColorBox::CMTextColorBox()
{
}
CMTextColorBox::~CMTextColorBox()
{
}
BEGIN_MESSAGE_MAP(CMTextColorBox, CComboBox)
//{{AFX_MSG_MAP(CMTextColorBox)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMTextColorBox message handlers
void CMTextColorBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your code to draw the specified item
ASSERT(lpDrawItemStruct->CtlType == ODT_COMBOBOX);
LPCTSTR lpszText;
CString strBox;
if(lpDrawItemStruct->itemID!=-1)
GetLBText(lpDrawItemStruct->itemID,strBox);
else
return;
lpszText=strBox.GetBuffer(0);
strBox.ReleaseBuffer(-1);
COLORREF BoxColor;
BoxColor=lpDrawItemStruct->itemData;
//strBox.ReleaseBuffer(-1);
ASSERT(lpszText != NULL);
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
// Save these value to restore them when done drawing.
COLORREF crOldTextColor = dc.GetTextColor();
COLORREF crOldBkColor = dc.GetBkColor();
crOldTextColor-=RGB(5,5,5);
// If this item is selected, set the background color
// and the text color to appropriate values. Erase
// the rect by filling it with the background color.
if ((lpDrawItemStruct->itemAction | ODA_SELECT) &&
(lpDrawItemStruct->itemState & ODS_SELECTED))
{
dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
dc.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
dc.FillSolidRect(&lpDrawItemStruct->rcItem, ::GetSysColor(COLOR_HIGHLIGHT));
}
else
dc.FillSolidRect(&lpDrawItemStruct->rcItem, crOldBkColor);
CRect rect=lpDrawItemStruct->rcItem;
rect.right=rect.left+rect.Height();
rect.DeflateRect(1,1);
CPen pen;
CPen *oPen;
pen.CreatePen(PS_SOLID,1,RGB(0,0,0));
oPen=dc.SelectObject(&pen);
int bkmode=dc.SetBkMode(TRANSPARENT);
dc.Rectangle(rect);
dc.SelectObject(oPen);
dc.SetBkMode(bkmode);
rect.DeflateRect(1,1);
// rect.DeflateRect(0,0,rect.Width()-rect.Height(),0);
dc.FillSolidRect(&rect,BoxColor);
dc.SetBkColor(crOldBkColor);
dc.SetTextColor(crOldTextColor);
CRect rectT;
rectT=lpDrawItemStruct->rcItem;
rectT.left=rect.right+2;
// Draw the text.
dc.DrawText(
lpszText,
strlen(lpszText),
&rectT,
// DT_CENTER|DT_SINGLELINE|DT_VCENTER);
DT_LEFT|DT_SINGLELINE|DT_VCENTER);
// Reset the background color and the text color back to their
// original values.
dc.SetTextColor(crOldTextColor);
dc.SetBkColor(crOldBkColor);
dc.Detach();
//if(this!=GetFocus())
// this->SetFocus();
// ShowDropDown(TRUE);
}
void CMTextColorBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
// TODO: Add your code to determine the size of specified item
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -