国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ListBox編程兩例

2019-11-17 05:24:46
字體:
來源:轉載
供稿:網友
1。 為ListBox添加水平方向的滾動條

SendMessage (ListBox1->Handle,LB_SETHORIZONTALEXTENT,ListBox1->Width + 32,0) ;

2。 為Listbox添加圖標

首先需要設置Listbox的Style屬性為lbOwnerDrawVariable;

const margin = 2 ; // Margin around each bitmap

//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1MeasureItem(TWinControl *Control, int Index,
int &Height)
{
Height = ImageList1->Height + margin * 2 ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1DrawItem(TWinControl *Control, int Index,
TRect &Rect, TOwnerDrawState State)
{
// 填充背景.
ListBox1->Canvas->FillRect (Rect) ;
// 畫出圖像.
ImageList1->Draw (ListBox1->Canvas, Rect.Left + margin, Rect.Top + margin, Index) ;

// 畫出文字.
String text = ListBox1->Items->Strings [Index] ;
// Center the text vertically in relation to the bitmap.
int off = (Rect.Bottom - Rect.Top - ListBox1->Canvas->TextHeight (text)) / 2 ;
ListBox1->Canvas->TextOut (Rect.Left + ImageList1->Width + 2 * margin,
Rect.Top + off,text) ;
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 兴国县| 来安县| 什邡市| 清镇市| 五指山市| 祁门县| 甘谷县| 营山县| 仁怀市| 廉江市| 古蔺县| 南澳县| 共和县| 区。| 东安县| 垦利县| 微博| 信丰县| 佛冈县| 凌源市| 忻州市| 长顺县| 山阳县| 澎湖县| 嘉荫县| 勃利县| 天长市| 肥东县| 长乐市| 广德县| 凭祥市| 瑞金市| 龙海市| 福清市| 伊川县| 若尔盖县| 达州市| 南投县| 调兵山市| 鄯善县| 屏东市|