📄 mp3listbox.cpp
字号:
// Mp3ListBox.cpp: implementation of the CMp3ListBox class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Mp3ListBox.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMp3ListBox::CMp3ListBox()
{
}
CMp3ListBox::~CMp3ListBox()
{
}
void CMp3ListBox::OnDrawItem(int /*nIDCtl*/, LPDRAWITEMSTRUCT lpdis)
{
const int MAX_TEXT_LENGTH = 255;
TCHAR tchBuffer[MAX_TEXT_LENGTH] = {0,};
int y;
TEXTMETRIC tm;
// Display the text associated with the item.
if(lpdis->itemID != -1
&& (GetItemData(lpdis->itemID) == LISTBOX_ITEM_IS_PLAYING
|| (lpdis->itemState & ODS_SELECTED)) )
{
GetItemText(lpdis->itemID, tchBuffer, MAX_TEXT_LENGTH);
GetTextMetrics(lpdis->hDC, &tm);
y = (lpdis->rcItem.bottom + lpdis->rcItem.top -
tm.tmHeight) / 2;
int nOldMode;
COLORREF crOldTextColor, crOldBkColor;
nOldMode = ::SetBkMode(lpdis->hDC,TRANSPARENT);
if( (lpdis->itemState & ODS_SELECTED) )
{
crOldTextColor = ::SetTextColor(lpdis->hDC, MP3_LB_SELECTED_TXEXTCOLOR);
crOldBkColor = ::SetBkColor(lpdis->hDC, MP3_LB_SELECTED_BKCOLOR);
} else
{
crOldTextColor = ::SetTextColor(lpdis->hDC, MP3_LB_PLAYING_TXEXTCOLOR);
crOldBkColor = ::SetBkColor(lpdis->hDC, MP3_LB_PLAYING_BKCOLOR);
}
ExtTextOut(lpdis->hDC,
3,
y,
ETO_OPAQUE,
&lpdis->rcItem,
tchBuffer,
_tcslen(tchBuffer),
NULL);
SetBkMode(lpdis->hDC,nOldMode);
SetTextColor(lpdis->hDC, crOldTextColor);
SetBkColor(lpdis->hDC, crOldBkColor);
}
else
{
CNListBox::OnDrawItem(0, lpdis);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -