简单自画菜单效果
<P>//---------------------------------------------------------------------------#include <vcl.h>
#pragma hdrstop</P>
<P>#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;</P>
<P>Graphics::TBitmap *bmp;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
bmp = new Graphics::TBitmap;
bmp->LoadFromFile("Bar.bmp");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BarItemMeasureItem(TObject *Sender,
TCanvas *ACanvas, int &Width, int &Height)
{
Width += 2; </P>
<P> Height *= BarItem->Parent->Count - 1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BarItemDrawItem(TObject *Sender, TCanvas *ACanvas,
TRect &ARect, bool Selected)
{
ACanvas->Draw(0, 0, bmp);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete bmp;
}
//---------------------------------------------------------------------------</P>
页:
[1]