kmusttywyc 发表于 2004-9-30 19:33

简单自画菜单效果

<P>//---------------------------------------------------------------------------
#include &lt;vcl.h&gt;
#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-&gt;LoadFromFile("Bar.bmp");         
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BarItemMeasureItem(TObject *Sender,
      TCanvas *ACanvas, int &amp;Width, int &amp;Height)
{
    Width += 2;                     </P>
<P>  Height *= BarItem-&gt;Parent-&gt;Count - 1;   
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BarItemDrawItem(TObject *Sender, TCanvas *ACanvas,
      TRect &amp;ARect, bool Selected)
{
    ACanvas-&gt;Draw(0, 0, bmp);               
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
    delete bmp;                           
}
//---------------------------------------------------------------------------</P>
页: [1]
查看完整版本: 简单自画菜单效果