数学建模社区-数学中国

标题: 简单自画菜单效果 [打印本页]

作者: kmusttywyc    时间: 2004-9-30 19:33
标题: 简单自画菜单效果
<>//---------------------------------------------------------------------------
$ @( q: M5 S: J" c7 y; O" G" ]#include &lt;vcl.h&gt;2 o% K+ P2 a+ A# z9 J5 \2 V) |2 e" Y2 T
#pragma hdrstop</P>8 M2 [) \  J( ]# d
<>#include "Unit1.h"
0 W5 {: f$ U! U//---------------------------------------------------------------------------! f9 p4 s. @. \" P5 |
#pragma package(smart_init)
9 y+ q" b" v# T#pragma resource "*.dfm"
% _- S& y( ]  tTForm1 *Form1;</P>! B: u6 _' @1 F7 @
<>Graphics::TBitmap *bmp;                     + i$ U0 {7 Y1 _% C( r
//---------------------------------------------------------------------------. W# L' U5 }2 Z2 g" S; h
__fastcall TForm1::TForm1(TComponent* Owner)
' t& K1 `$ ]. Q6 U    : TForm(Owner)! x- n  ~  c& L+ Z* t% s
{
, Y6 \1 R2 x2 f& v    bmp = new Graphics::TBitmap;           5 c. v  E# `9 d/ b) m8 A( t
    bmp-&gt;LoadFromFile("Bar.bmp");         
: i& \) B  S8 z( z0 ?}
  t% [) w2 K% Z//---------------------------------------------------------------------------* `' l. q6 O: |* h) ^
void __fastcall TForm1::BarItemMeasureItem(TObject *Sender,
6 L8 J0 h8 `! e% N. P      TCanvas *ACanvas, int &amp;Width, int &amp;Height)
9 Y. C' ~, ?; c5 h{
0 A: B0 N' w' C  h) u: }$ ]6 g2 ^    Width += 2;                     </P>
$ x" h$ [5 h" `( Z4 Q; C$ |* ]<>  Height *= BarItem-&gtarent-&gt;Count - 1;   4 ]6 i. W3 ~' M
}
$ U8 k( q: n( p8 ]; Q) }; G//---------------------------------------------------------------------------
, Z8 S6 q7 c% ?void __fastcall TForm1::BarItemDrawItem(TObject *Sender, TCanvas *ACanvas,
; T+ U) ]% ]+ y. x$ l      TRect &amp;ARect, bool Selected)
0 N  b4 M1 l) g) s. A9 c  Q{% I3 ?* R' U; y: x% ], V
    ACanvas-&gt;Draw(0, 0, bmp);               / N3 U# i1 l  W& V
}
8 h$ d* q9 P! x$ N! g! ?* m! G//---------------------------------------------------------------------------% o6 `8 O3 {+ I( I
void __fastcall TForm1::FormDestroy(TObject *Sender). Y( c9 h2 _8 U: D
{. C1 L8 C2 O& V' v
    delete bmp;                            . D8 r) h7 n3 v. v
}
. c8 Y! ~  Y9 H: X0 x3 z2 }! ^//---------------------------------------------------------------------------</P>




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5