• Sábado 4 de Mayo de 2024, 19:04

Autor Tema:  Problemas Con Picturebox Y Point  (Leído 876 veces)

davidpfc

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Problemas Con Picturebox Y Point
« en: Jueves 26 de Enero de 2006, 16:18 »
0
Hola a todos y gracias de antemano por ayudarme, os explico:

Estoy haciendo un programa en VB que mueve un cursor por un picturebox este picturebox tiene unas lineas dibujadas por las que se supone no deberia pasar el cursor, para esto se me habia ocurrido usar la funcion point (si point me devuelve un valor distinto del valor en el que esta actualmente el cursor no se podra mover en esa direccion, no se si me explico bien). Pues bien, point me devuleve solo dos valores distintos dentro del picturebox y de las lineas pasa olimpicamente. me gustaria que alguien me echase una mano por favor a ver si se les ocurre algo o saben de otra forma de hacerlo.

un ej. seria como mover un punto por el picture y decirle que si se esta moviendo a un pixel de color diferente de blanco no se mueva.

Gracias!

Pongo mi codigo por si a alguien le interesa:

Option Explicit
Dim ActualPoint As Long
Dim ContX, ContY As Long

Private Sub Command1_Click()    'ABAJO
ActualPoint = Point(ContX, ContY)
ContY = ContY + 1
If Point(ContX, ContY) <> ActualPoint Then ContY = ContY - 1
If ContY > XYGraf.Height Then ContY = ContY - 1
DrawXY ContX, ContY
End Sub

Private Sub Command2_Click()    'ARRIBA
ActualPoint = Point(ContX, ContY)
ContY = ContY - 1
If Point(ContX, ContY - 1) <> ActualPoint Then ContY = ContY + 1
If ContY < 0 Then ContY = ContY + 1
DrawXY ContX, ContY
End Sub

Private Sub Command3_Click()    'DERECHA
ActualPoint = Point(ContX, ContY)
ContX = ContX + 1
If Point(ContX, ContY - 1) <> ActualPoint Then ContX = ContX - 1
If ContX > XYGraf.Width Then ContX = ContX - 1
DrawXY ContX, ContY
End Sub

Private Sub Command4_Click()    'IZQUIERDA
ActualPoint = Point(ContX, ContY)
ContX = ContX - 1
If Point(ContX, ContY - 1) <> ActualPoint Then ContX = ContX + 1
If ContX < 0 Then ContX = ContX + 1
DrawXY ContX, ContY
End Sub

Private Sub Form_Load()
ContX = XYGraf.Width / 2
ContY = XYGraf.Height / 2

End Sub

Public Sub DrawXY(ByVal X As Long, ByVal Y As Long)     'DIBUJA LA CRUZ DEL PUNTERO

XYGraf.Cls

XYGraf.Line (X - 3, Y)-(X + 3, Y), &HFF
XYGraf.Line (X, Y - 3)-(X, Y + 3), &HFF

Label1.Caption = X
Label2.Caption = Y
Label5.Caption = Point(X, Y)

End Sub

 :comp: