![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
||||
|
||||
|
Guauuuuu, tio no se que haria yo mal, quizas es que activas alguna propiedad o algo pero tu proyecto va muy bien y solo le hice un par de cambios para que funcione mas o menos como quiero porque por ejemplo en el tuyo cuando mueves automaticamente el puntero se va a la posicion x=0, y=0 de la imagen y le quité lo de que tenga que pulsar la tecla de Ctrol y va genia pero me falta un detalle:
Código:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TPoint *TheSpot = new TPoint;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
bool Moving = false;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Image1->Picture->LoadFromFile(ExtractFilePath(Application->ExeName)+
"LogoRad.bmp");
}
void __fastcall TForm1::ControlMouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
//Moving = Shift.Contains(ssCtrl);
Moving = true;
TheSpot->x = X;
TheSpot->y = Y;
}
void __fastcall TForm1::ControlMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
TControl *Ctrl = static_cast<TControl*>(Sender);
if (Moving) {
Screen->Cursor = crCross;
Ctrl->Left = X + Ctrl->Left - TheSpot->x;
Ctrl->Top = Y + Ctrl->Top - TheSpot->y;
}
}
void __fastcall TForm1::ControlMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
Moving = false;
Screen->Cursor = crDefault;
}
|
|
#2
|
||||
|
||||
|
He probado esto:
Código:
if((Ctrl->Left + X + Ctrl->Left - TheSpot->x < 0) || (Ctrl->Left < 0 && Ctrl->Width + Ctrl->Left - ScrollBox1->Width >= 0))
{
Ctrl->Left = X + Ctrl->Left - TheSpot->x;
}
|
|
#3
|
||||
|
||||
|
Al final lo he conseguido con esto:
Código:
void __fastcall TForm1::ControlMouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
TControl *Ctrl = static_cast<TControl*>(Sender);
if (Moving)
{
if((Ctrl->Left + X + Ctrl->Left - TheSpot->x <= 0) &&
(Ctrl->Width + Ctrl->Left + X + Ctrl->Left - TheSpot->x - ScrollBox1->Width >= 0) &&
(Ctrl->Top + Y + Ctrl->Top - TheSpot->y <= 0) &&
(Ctrl->Height + Ctrl->Top + Y + Ctrl->Top - TheSpot->y - ScrollBox1->Height >= 0))
{
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 + Ctrl->Left + X + Ctrl->Left - TheSpot->x - ScrollBox1->Width >= 0))
{
Ctrl->Left = X + Ctrl->Left - TheSpot->x;
}
else if((Ctrl->Top + Y + Ctrl->Top - TheSpot->y <= 0) &&
(Ctrl->Height + Ctrl->Top + Y + Ctrl->Top - TheSpot->y - ScrollBox1->Height >= 0))
{
Ctrl->Top = Y + Ctrl->Top - TheSpot->y;
}
}
}
![]() |
|
#4
|
||||
|
||||
|
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;
}
}
}
|
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Pasar estructura Type de delphi a Builder.. | Novatin | C++ Builder | 4 | 31-05-2013 19:00:35 |
| pasar codigo de delphi a c++ Builder | rxaxx9 | C++ Builder | 2 | 13-05-2012 06:27:17 |
| codigo en delphi a c++ builder | zidfrid | C++ Builder | 4 | 09-07-2008 14:34:29 |
| Convertir codigo Delphi a Builder | _Willa | C++ Builder | 3 | 15-02-2008 11:37:10 |
| Cambiando el codigo de delphi a builder... | paco_galo | C++ Builder | 5 | 03-12-2007 22:14:54 |
|