让标题栏文字居中

王朝vb·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

让标题栏文字居中

|添加以下模块:

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航