Initial commit
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
//---------------------------------------------------------------------------
|
||||
#include "UpdateListBoxUnit.h"
|
||||
#include "GlobalUnit.h"
|
||||
#pragma package(smart_init)
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
__fastcall UpdateListBoxUnit::TListBox::TListBox(System::Classes::TComponent* AOwner)
|
||||
: TSkinListBox(AOwner)
|
||||
{
|
||||
m_imgBackground = new TBitmap();
|
||||
m_imgBackground->LoadFromResourceName(int(HInstance),"CustomPanelBackground");
|
||||
m_pFntText = new TFont();
|
||||
m_pFntText->Name = "黑体";
|
||||
m_pFntText->Size = 9;
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
__fastcall UpdateListBoxUnit::TListBox::~TListBox()
|
||||
{
|
||||
if( m_imgBackground ){
|
||||
delete m_imgBackground;
|
||||
}
|
||||
|
||||
if( m_pFntText ){
|
||||
delete m_pFntText;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall UpdateListBoxUnit::TListBox::WMPaint(Winapi::Messages::TWMPaint &Message)
|
||||
{
|
||||
DefaultHandler( &Message );
|
||||
|
||||
if( Items->Count==0 ){
|
||||
TRect rectClient(0,0,ClientWidth,ClientHeight);
|
||||
|
||||
//绘制底图
|
||||
rectClient.left++;
|
||||
rectClient.right--;
|
||||
rectClient.top++;
|
||||
rectClient.bottom--;
|
||||
Canvas->StretchDraw( rectClient, m_imgBackground );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall UpdateListBoxUnit::TListBox::DrawItem(int Index, const System::Types::TRect &Rect, Winapi::Windows::TOwnerDrawState State)
|
||||
{
|
||||
TRect rcDraw, rcOrig = Rect;
|
||||
if( rcOrig.Width()<Width ){ //显示滚动条
|
||||
rcOrig.right = Width-19; //减去滚动条宽度
|
||||
}
|
||||
rcDraw = rcOrig;
|
||||
|
||||
Canvas->StretchDraw( rcDraw, m_imgBackground );
|
||||
Canvas->Brush->Style = bsClear;
|
||||
|
||||
if( State.Contains(odSelected) ){
|
||||
Canvas->Font->Color = clBlack;
|
||||
if(State.Contains(odFocused))
|
||||
DrawFocusRect(Canvas->Handle, &Rect);
|
||||
}
|
||||
|
||||
Canvas->TextOut( Rect.Left+8, Rect.Top+1, Items->Strings[Index]);
|
||||
|
||||
if( Index==Items->Count-1 && Rect.bottom<Height ){ //绘制空白部分
|
||||
TRect rcBlank( rcOrig.left, Rect.bottom , Rect.right, Height );
|
||||
Canvas->StretchDraw( rcBlank, m_imgBackground );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user