Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 12-04-2008
Avatar de pborges36
pborges36 pborges36 is offline
Miembro
 
Registrado: oct 2004
Ubicación: Argentina
Posts: 192
Poder: 20
pborges36 Va por buen camino
evento WMWindowPosChanging en TForm

Holas. Necesito una ayuda. Estoy tratando de hacer un componente devirado de un TEdit, TKEdit, el cual, entre otras cosas, deberia habilitarme barras flotantes. Estuve viendo un ejemplo de nuestro amigo Neftali.

Código Delphi [-]
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Label2Click(Sender: TObject);
    procedure FormResize(Sender: TObject);
  private
    { Private declarations }
    procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
    procedure WMNCLButtonDown(var Message: TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
    procedure _MoveFW();
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
uses Unit2, Unit3, ShellAPI;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.Visible := not Form2.Visible;
  Form3.Visible := not Form3.Visible;
  _MoveFW();
end;

procedure TForm1.WMWindowPosChanging(var Message: TWMWindowPosChanging);
begin
  _MoveFW();
  inherited;
end;
procedure TForm1.Label2Click(Sender: TObject);
begin
    ShellExecute(Handle,
             'open',
             'http://neftali.clubdelphi.com/',
             nil,
             nil,
             SW_SHOW);
end;

procedure TForm1.WMNCLButtonDown(var Message: TWMNCLButtonDown);
begin
  _MoveFW();
  inherited;
end;
procedure TForm1._MoveFW;
begin
//  if (Self.ComponentState <> []) then begin
//    Exit;
//  end;
  if not Assigned(Form2) then begin
    Exit;
  end;
  if not Assigned(Form3) then begin
    Exit;
  end;
  if (Form2.Visible) then begin
    // Posicionar las barras
    Form2.Top := Self.Top - Form2.Height;
    Form2.Left := Self.Left;
  end;
  if (Form3.Visible) then begin
    // Posicionar las barras
    Form3.Top := Self.Top;
    Form3.Left := Self.LEft + Self.Width;
  end;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
  _MoveFW();
end;
end.

Form2 y Form3 son las barras flotantes y este ejemplo funciona a la perfeccion.
¿Como hago para asignarle desde el TKEdit los procedures WMWindowPosChanging, WMNCLButtonDown y FormResize al TForm que lo contiene?

El TKEdit esta mas o menos asi.

Código Delphi [-]
unit UnitKEdit;
interface
uses
  SysUtils, Classes, Controls, StdCtrls, Messages, Forms;
type
  TKEditi = class(TEdit)
  private
    { Private declarations }
    procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;
    procedure WMNCLButtonDown(var Message: TWMNCLButtonDown); message WM_NCLBUTTONDOWN;
    procedure _MoveFW();
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner : TComponent); override;    {Constructor}
  published
    { Published declarations }
  end;
procedure Register;
implementation
uses Unitbarra_horizontal, Unitbarra_vertical, ShellAPI;
procedure Register;
begin
  RegisterComponents('customer', [TKEdit]);
end;

constructor TKEdit.Create(AOwner : TComponent);
begin
    inherited Create(AOwner);
    barra_vertical:=Tbarra_vertical.Create(self);
    barra_horizontal:=Tbarra_horizontal.Create(self);
    barra_vertical.Visible:=true;
    barra_horizontal.Visible:=true;
    try
    _MoveFW;
    except
    end;
end;
procedure TKEdit._MoveFW;
begin
  if not Assigned(barra_vertical) then begin
    Exit;
  end;
  if not Assigned(barra_horizontal) then begin
    Exit;
  end;
  if (barra_vertical.Visible) then begin
    // Posicionar las barras
    barra_vertical.Top := Self.Parent.Top - barra_vertical.Height;
    barra_vertical.Left := Self.Parent.Left;
  end;
  if (barra_horizontal.Visible) then begin
    // Posicionar las barras
    barra_horizontal.Top := Self.Parent.Top;
    barra_horizontal.Left := Self.Parent.LEft + Self.Parent.Width;
  end;
end;
procedure TKEdit.WMWindowPosChanging(var Message: TWMWindowPosChanging);
begin
  _MoveFW();
  inherited;
end;
procedure TKEdit.WMNCLButtonDown(var Message: TWMNCLButtonDown);
begin
  _MoveFW();
  inherited;
end;
 
end.
Gracias!
Responder Con Cita
 



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
Formato de salida en TForm aanil OOP 9 11-04-2008 02:36:15
Ejecutar Tform pmtzg Varios 1 01-04-2008 15:09:42
Buscar clases en un TForm. eduarcol OOP 13 28-02-2008 22:30:11
Refrescar mi tform.... Kamikaze OOP 3 17-11-2004 22:09:25
Onkeyup, down y press en el TForm erickperez6 Varios 1 14-10-2003 14:50:39


La franja horaria es GMT +2. Ahora son las 08:05:07.


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