Let the title bar text

zhaozj2021-02-11  224

Let the title bar text

| Add the following modules:

Publicsubcenterc (frMasform)

Dimspcfasinteger'howManySpacescanfit

Dimclenasinteger'captionLength

DIMOLDCASSTRING'OLDCAPTION

DimiasInteger'Notimportant

'' RemoveanySpacesatthendsofthecaption

'' VeryAsYifyoureaditcarefully

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''howmanspacecanfit 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

| Add the following code in the form:

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

转载请注明原文地址:https://www.9cbs.com/read-4881.html

New Post(0)