![]() |
![]() |
| 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
|
|||
|
|||
|
Error al mover componentes en tiempo de ejecución
Hola, sucede que en una aplicación quiero que el usuario pueda mover los componentes, asi que use el siguiente código:
Código:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
bool Mover = false;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Mover = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1MouseUp(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
Mover = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListBox1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
if(Mover == true) {
TPoint *nPoint2;
GetCursorPos(nPoint2);
ListBox1->Left = (nPoint2->x - Form1->Left) - ListBox1->Width/2;
ListBox1->Top = (nPoint2->y - Form1->Top) - ListBox1->Width/2;
};
}
//---------------------------------------------------------------------------
![]() |
|
#2
|
||||
|
||||
|
Hola DSK25.
El error es por que estas haciendo mal la creación del puntero nPoint2. No probé el código (no sé si hace lo que buscas) pero debería ser: Código:
void __fastcall TForm1::ListBox1MouseMove(TObject *Sender,
TShiftState Shift, int X, int Y)
{
if(Mover == true) {
TPoint *nPoint2 = new TPoint;
__try {
GetCursorPos(nPoint2);
ListBox1->Left = (nPoint2->x - Form1->Left) - ListBox1->Width/2;
ListBox1->Top = (nPoint2->y - Form1->Top) - ListBox1->Width/2;
}
__finally {
delete nPoint2;
}
};
}
Código:
void __fastcall TForm1::ListBox1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
ReleaseCapture;
SendMessage(ListBox1->Handle, WM_SYSCOMMAND, 0xF012, 0);
}
__________________
Daniel Didriksen Guía de estilo - Uso de las etiquetas - La otra guía de estilo .... |
|
#3
|
|||
|
|||
|
Gracias ecfisa, me funciono
. |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Mover un label en tiempo de ejecución | CarlosAlberto | Varios | 7 | 23-03-2012 18:44:23 |
| Mover un panel en tiempo ejecución por el form | CarlosAlberto | Varios | 3 | 10-08-2011 10:16:53 |
| Mover caida de impresión en tiempo de ejecución | osmuar_exp | Impresión | 2 | 22-03-2008 12:36:32 |
| cambiar tamaño y mover componentes creados en tiempo de ejecucion | gulder | API de Windows | 4 | 18-11-2006 23:21:16 |
| mover componentes en tiempo de ejecución | Dantael | OOP | 3 | 06-02-2005 12:29:46 |
|