Ver Mensaje Individual
  #12  
Antiguo 03-06-2013
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Reputación: 11
aguml Va por buen camino
Me di cuenta de que algo raro pasaba y que hacia la derecha y hacia abajo no mostraba toda la imagen y al final queda así:

Código:
void __fastcall TForm1::ImageMouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
        //Aqui hacemos que cuando arrastremos la imagen esta se vaya moviendo por el ScrollBox
        //y le asignamos el cursor deseado
        TControl *Ctrl = static_cast<TControl*>(Sender);

        if (Moving)
        {
                if((Ctrl->Left + X + Ctrl->Left - TheSpot->x <= 0) &&
                   (Ctrl->Width - ScrollBox->Width + Ctrl->Left + X - TheSpot->x >= -3) &&
                   (Ctrl->Top + Y + Ctrl->Top - TheSpot->y <= 0) &&
                   (Ctrl->Height - ScrollBox->Height + Ctrl->Top + Y - TheSpot->y >= -3))
                {
                        Ctrl->Left = X + Ctrl->Left - TheSpot->x;
                        Ctrl->Top  = Y + Ctrl->Top - TheSpot->y;
                }
                else if((Ctrl->Left + X + Ctrl->Left - TheSpot->x <= 0) &&
                   (Ctrl->Width - ScrollBox->Width + Ctrl->Left + X - TheSpot->x >= -3))
                {
                        Ctrl->Left = X + Ctrl->Left - TheSpot->x;
                }
                else if((Ctrl->Top + Y + Ctrl->Top - TheSpot->y <= 0) &&
                   (Ctrl->Height - ScrollBox->Height + Ctrl->Top + Y - TheSpot->y >= -3))
                {
                        Ctrl->Top  = Y + Ctrl->Top - TheSpot->y;
                }
        }
}
Funciona bien pero no se porque cuando llego al final de la imagen le falta un pelin para llegar al final de ella y tengo que soltar, hacer clic de nuevo y volver a arrastrar. El -3 es porque el borde del ScrollBox me tapa un pelin la imagen por alli y con ese -3 se ve entera.
Responder Con Cita