让标题栏文字居中

来源:互联网 发布:安卓软件源码是什么 编辑:程序博客网 时间:2024/05/01 20:42
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
让标题栏文字居中
|添加以下模块:

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

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击