Foro de elhacker.net

Programación => 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
  1. Private Sub form_load()
  2.    ScaleMode = 3
  3.    AutoRedraw = True
  4.    CurrentX = ScaleWidth / 2
  5.    CurrentY = ScaleHeight / 2
  6.    Print "Este texto deberia estar centrado!, Automaticamente!"
  7.    CurrentX = 0
  8.    CurrentY = 0
  9.    Print "Esto deberia ajustarse automaticamente a la anchura del form, si se pasa entonces se deberia brincar a una linea nueva! , Automaticamente!"
  10. End Sub
  11.  

Gracias!


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

Código:

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! ;-)