Centrovßnφ titulku okna

Postup:
Zalo₧te nov² projekt. V n∞m deklarujte nßsledujφcφ prom∞nnou a zapiÜte proceduru:

Dim oldsize As Long

Public Sub CenterC(frm As Form)
   Dim SpcF As Integer
'poΦφtadlo mezer
    Dim clen As Integer 'dΘlka titulku
   Dim oldc As String    'p∙vodnφ titulek
   Dim i As Integer

    'odstran∞nφ mezer ZA titulkem
   oldc = frm.Caption

    Do While Left(oldc, 1) = Space(1)
      DoEvents
      oldc = Right(oldc, Len(oldc) - 1)
    Loop

    Do While Right(oldc, 1) = Space(1)
      DoEvents
      oldc = Left(oldc, Len(oldc) - 1)
    Loop

    clen = Len(oldc)

    If InStr(oldc, "!") <> 0 Then
       If InStr(oldc, " ") <> 0 Then
          clen = clen * 1.5
       Else
          clen = clen * 1.4
       End If
   Else
       If InStr(oldc, " ") <> 0 Then
           clen = clen * 1.4
       Else
           clen = clen * 1.3
       End If
   End If

    'kolik se vejde znak∙
    SpcF = frm.Width / 61.2244
    SpcF = SpcF - clen

  
If SpcF > 1 Then
        DoEvents
        frm.Caption = Space(Int(SpcF / 2)) + oldc
    Else
'pokud je formulß° pro mezery p°φliÜ mal²
      frm.Caption = oldc
    End If

End Sub

Na udßlost Form_Load zapiÜte:

CenterC Me
oldsize = Me.Width

a na udßlost Form_Resize:

If Me.Width = oldsize Then
   
'nezm∞nila se velikost formulß°e
    Exit Sub
Else
     CenterC Me
     oldsize = Me.Width
End If

Spus¥te projekt. Titulek se jak₧ tak₧ vycentruje, asi by to cht∞lo trochu lΘpe spoΦφtat.

Zp∞t

Autor: The Bozena