Test Foro de elhacker.net SMF 2.1

Programación => .NET (C#, VB.NET, ASP) => Programación General => Programación Visual Basic => Mensaje iniciado por: ignorantev1.1 en 14 Octubre 2010, 01:07 AM

Título: Justificar, Centrar Fuentes [DUDA]
Publicado por: ignorantev1.1 en 14 Octubre 2010, 01:07 AM
Hola que tal, tengo una duda sobre las fuentes. Si quiero hacer un proyecto donde utilize el metodo "print" y "currentx, Currenty" para pintar fuentes en algun form, como puedo, por ejemplo, centrar lo que se pintara?. Es decir como saber cuando mide lo que se esta escribiendo?

Código (vb) [Seleccionar]
Private Sub form_load()
    ScaleMode = 3
    AutoRedraw = True
    CurrentX = ScaleWidth / 2
    CurrentY = ScaleHeight / 2
    Print "Este texto deberia estar centrado!, Automaticamente!"
    CurrentX = 0
    CurrentY = 0
    Print "Esto deberia ajustarse automaticamente a la anchura del form, si se pasa entonces se deberia brincar a una linea nueva! , Automaticamente!"
End Sub


Gracias!
Título: Re: Justificar, Centrar Fuentes [DUDA]
Publicado por: Dessa en 14 Octubre 2010, 01:53 AM
Hola , probá si asi te sirve



Option Explicit

Private Sub Form_Load()

  Me.AutoRedraw = True
  Me.FontBold = True

  Dim variable As String
  variable = "Este texto deberia estar centrado!"

  Me.CurrentY = Me.ScaleHeight / 2 - Me.TextHeight(variable) / 2
  Me.CurrentX = Me.ScaleWidth / 2 - Me.TextWidth(variable) / 2

  Me.Print variable

End Sub




Título: Re: Justificar, Centrar Fuentes [DUDA]
Publicado por: ignorantev1.1 en 14 Octubre 2010, 02:17 AM
Exactamente es lo que buscaba, muchas gracias! ;-)