让标题栏文字居中

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 shawls 的 blog

让标题栏文字居中
|添加以下模块:

publicsubcenterc(frmasform)

dimspcfasinteger'howmanyspacescanfit

dimclenasinteger'captionlength

dimoldcasstring'oldcaption

dimiasinteger'notimportant

''removeanyspacesattheendsofthecaption

''veryeasyifyoureaditcarefully

oldc=frm.caption

dowhileleft(oldc,1)=space(1)

doevents

oldc=right(oldc,len(oldc)-1)

loop

dowhileright(oldc,1)=space(1)

doevents

oldc=left(oldc,len(oldc)-1)

loop

clen=len(oldc)

ifinstr(oldc,"!")<>0then

ifinstr(oldc,"")<>0then

clen=clen*1.5

else

clen=clen*1.4

endif

else

ifinstr(oldc,"")<>0then

clen=clen*1.4

else

clen=clen*1.3

endif

endif

'''seehowmanycharacterscanfit

spcf=frm.width/61.2244''howmanyspacecanfit itthecaption

spcf=spcf-clen'howmanyspacescanfit-howmuch spacethe

''captiontakesup

'''nowthetrickypart

ifspcf>1then

doevents'speeduptheprogram

frm.caption=space(int(spcf/2))+oldc

else'iftheformistoosmallforspaces

frm.caption=oldc

endif

endsub

|在窗体中添加以下代码:

dimoldsizeaslong

privatesubform_resize()

ifme.width=oldsizethen'ifthewidthhasn't changed

exitsub'thendontmesswithit

else

centercme

oldsize=me.width

endif

endsub

privatesubform_load()

centercme

oldsize=me.width

endsub

本文关键:标题栏,居中
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top