Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 19-10-2015
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.210
Poder: 22
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Ejemplo simple reescribiendo la función virtual WndProc de un formulario:

Código PHP:
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:    // IDE-managed Components
private:    // User declarations
protected:
  
virtual void __fastcall WndProc(TMessagemsg);
public:        
// User declarations
  
__fastcall TForm1(TComponentOwner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif 
Código PHP:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponentOwner)
  : 
TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::WndProc(TMessagemsg)
{
  if(
msg.Msg == WM_MOVING){
    
TRect *= (TRect*)msg.LParam;
    if(
R->Left 50){
      
R->Left 50;
      
R->Right Left Width;
    }
  }
  
TForm::WndProc(msg);

Este ejemplo impide desplazar el formulario a la izquierda más allá del valor 50.


Saludos.
Responder Con Cita
  #2  
Antiguo 20-10-2015
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 14
aguml Va por buen camino
Muy bien, guiandome de tu codigo y de otro que encontré por la red en ruso pude sacar este codigo:
En el .h
Código PHP:
private:    // User declarations
   
void __fastcall CatchDrag(TMessage &Msg);
protected:
  
BEGIN_MESSAGE_MAP
  VCL_MESSAGE_HANDLER
(WM_MOVINGTMessageCatchDrag);
  
END_MESSAGE_MAP(TForm
En el .cpp:
Código PHP:
void __fastcall TFormHijo::CatchDrag(TMessage &Msg)
{
   
TForm::Dispatch(&Msg);
   if(
Msg.Msg == WM_MOVING){
      
PRECT pCurrentRec PRECT(Msg.LParam);

      
//El 5 creo que es por los bordes de la ventana padre
      
if(pCurrentRec->left FormPadre->Left 5){
         
pCurrentRec->left FormPadre->Left 5;
         
pCurrentRec->right Left Width 5;
      }else if(
pCurrentRec->right FormPadre->Left FormPadre->Width 5){
         
pCurrentRec->left FormPadre->Left + (FormPadre->Left FormPadre->Width - (Left Width) - 5);
         
pCurrentRec->right FormPadre->Left FormPadre->Width 5;
      }
      
//Tengo un Panel alineado arriba y el 32 creo que es porque es lo que mide
      //barra de titulo de la ventana padre
      
if(pCurrentRec->top FormPadre->Top FormPadre->Panel->Height 32){
         
pCurrentRec->top FormPadre->Top FormPadre->Panel->Height 32;
         
pCurrentRec->bottom Top Height 32;
      }else if(
pCurrentRec->bottom FormPadre->Top FormPadre->Height 5){
         
pCurrentRec->top FormPadre->Top + (FormPadre->Top FormPadre->Height - (Top Height)) - 5;
         
pCurrentRec->bottom FormPadre->Top FormPadre->Height 5;
      }
      
Caption "LeftBeforeMove: " IntToStr(pCurrentRec->left) +
                
"  TopBeforeMove: " IntToStr(pCurrentRec->top);
   }

El problema que tengo es que me redimensiona la ventana hija y no veo la manera de solucionarlo. O sea que no me respeta el tamaño que tenia la ventana hija y es porque algo hago mal al darle el right y el bottom.

Última edición por aguml fecha: 20-10-2015 a las 09:45:27.
Responder Con Cita
  #3  
Antiguo 20-10-2015
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 14
aguml Va por buen camino
He intentado editar el mensaje anterior pero he llegado tarde por muy poquito y ya no me dejaba asi que lo pongo aqui. Ya he conseguido hacerlo. Al final coji papel y lapiz y lo plantee sobre el papel y me di cuenta de los fallos y asi quedó:
En el .h:
Código PHP:
private:    // User declarations
   //Necesarias para arrastrar la imagen por el ScrollBox
   
void __fastcall CatchDrag(TMessage &Msg);
protected:
  
BEGIN_MESSAGE_MAP
  VCL_MESSAGE_HANDLER
(WM_MOVINGTMessageCatchDrag);
  
END_MESSAGE_MAP(TForm
En el .cpp:
Código PHP:
void __fastcall TFormHijo::CatchDrag(TMessage &Msg)
{
   
TForm::Dispatch(&Msg);
   if(
Msg.Msg == WM_MOVING){
      
PRECT pCurrentRec PRECT(Msg.LParam);

      
//El 5 creo que es por los bordes de la ventana padre
      
if(pCurrentRec->left FormPadre->Left 5){
         
pCurrentRec->left FormPadre->Left 5;
         
pCurrentRec->right FormPadre->Left Width 5;
      }else if(
pCurrentRec->right FormPadre->Left FormPadre->Width 5){
         
pCurrentRec->left FormPadre->Left FormPadre->Width Width 5;
         
pCurrentRec->right FormPadre->Left FormPadre->Width 5;
      }
      
//Tengo un Panel alineado arriba y el 32 creo que es porque es lo que mide
      //barra de titulo de la ventana padre
      
if(pCurrentRec->top FormPadre->Top FormPadre->Panel->Height 32){
         
pCurrentRec->top FormPadre->Top FormPadre->Panel->Height 32;
         
pCurrentRec->bottom FormPadre->Top FormPadre->Panel->Height Height 32;
      }else if(
pCurrentRec->bottom FormPadre->Top FormPadre->Height 5){
         
pCurrentRec->top FormPadre->Top FormPadre->Height Height 5;
         
pCurrentRec->bottom FormPadre->Top FormPadre->Height 5;
      }
      
Caption "LeftBeforeMove: " IntToStr(pCurrentRec->left) +
                
"  TopBeforeMove: " IntToStr(pCurrentRec->top);
   }

La verdad es que ahora me gustaria meterme con el codigo que hiciste en delphi que con el uso de las MDI lo veo poco util pero muy interesante y me ha picado el gusanillo y quiero pasarlo a C++Builder para entender su funcionamiento. Muchas gracias por todo.
Responder Con Cita
  #4  
Antiguo 21-10-2015
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.210
Poder: 22
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Pues la traducción del ejemplo que te puse al sistema de tratamiento de mensajes tipo delphi sería esta:
Código PHP:
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
struct TWMMoving{
  
DWORD Msg;
  
int   Edge;
  
PRect DragRect;
};

class 
TForm2 : public TForm
{
__published:    // IDE-managed Components
private:
  
__fastcall WMMoving(TWMMoving &Message);
public:        
// User declarations
  
__fastcall TForm2(TComponentOwner);

BEGIN_MESSAGE_MAP
  VCL_MESSAGE_HANDLER
(WM_MOVINGTWMMovingWMMoving)
END_MESSAGE_MAP(TForm)
};
//---------------------------------------------------------------------------
extern PACKAGE TForm2 *Form2;
//---------------------------------------------------------------------------
#endif 
Código PHP:
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;


//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponentOwner)
  : 
TForm(Owner)
{
}
//---------------------------------------------------------------------------

__fastcall TForm2::WMMoving(TWMMoving &Message)
{
  if(
Message.DragRect->Left 50){
    
Message.DragRect->Left 50;
    
Message.DragRect->Right Left Width;
  }

Saludos.
Responder Con Cita
  #5  
Antiguo 21-10-2015
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Poder: 14
aguml Va por buen camino
Ok muchas gracias. Seguiré investigando.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Popup de la barra de titulo _cero_ C++ Builder 2 05-06-2008 18:02:21
cual es el evento contrario a onmousemove? carlosmat21 Gráficos 3 20-07-2007 16:46:37
Escribir en la barra de título marcoszorrilla Trucos 0 29-06-2006 22:50:13
URL en la barra de titulo??? Jonnathan Varios 7 30-01-2006 20:43:24
Capturar El Evento Onmousemove ANTONIOGALISTEO OOP 4 18-09-2003 09:16:01


La franja horaria es GMT +2. Ahora son las 04:24:55.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi