Delphi改變選單字型

2021-06-12 17:33:04 字數 856 閱讀 8302

窗體上放一mainmenu1,包含的選單項為menuitem1,menuitem2...

設定為mainmenu的ownerdraw為true,

menuitem1的ondrawitem事件:

procedure tform1.menuitem1drawitem(sender: tobject; acanvas: tcanvas;

arect: trect; selected: boolean);

begin

acanvas.fillrect(arect);

acanvas.font.size:=20;    //設定為足夠大的字型大小

acanvas.font.name:='times new roman';  //設定為你喜歡的字型

//輸出選單項

acanvas.textout(arect.left,arect.top,(sender as tmenuitem).caption);  

end;

menuitem1的onmeasureitem事件:

procedure tform1.menuitem1measureitem(sender: tobject; acanvas: tcanvas;

var width, height: integer);

begin

height:=40;   //設定為足夠高以容納你的選單項

width:=200;  //設定為足夠寬以容納你的選單項

end;

將其他選單項的ondrawitem設定為menuitem1drawitem

onmeasureitem設定為menuitem1drawitem

上述**在我的機器上(d6+winxp)測試通過

自繪選單Menu字型改變大小

delphi 自繪選單menu字型改變大小 menu選單的屬性面板是沒有font屬性的,可以通過寫 來改變選單字型大小。窗體上放一mainmenu1,包含的選單項為menuitem1,menuitem2.設定為mainmenu的ownerdraw為true,menuitem1的ondrawitem事...

改變 DrawText 字型

cfontfont verify font.createpointfont 180,arial pdc 建立字型 arial格式 180為字高 font def font pdc selectobject font 選擇該字型進入pdc m size pdc gettextextent tmp lp...

Spinner改變字型

arrayadapteradapter arrayadapter.createfromresource this,r.array.profession item,r.layout.myspinner dropdown myspinner dropdown.xml profession.xml 計算機...