Ver Mensaje Individual
  #52  
Antiguo 07-04-2013
Avatar de cesarsoftware
cesarsoftware cesarsoftware is offline
Miembro
 
Registrado: nov 2006
Posts: 241
Reputación: 20
cesarsoftware Va por buen camino
Con tu codigo en el formulario principal, el movimiento de las ventanas hijas es mucho mas fino, sigue sin funcionar en server 2003, pero no me importa demasiado (ahora en vez de dejar las ventanas hijas donde estan las mueve arriba y a la izquerda a toda velocidad).
Código Delphi [-]
procedure WMMoving(var Message: TWMMOVING); message WM_MOVING;

procedure TFormMain.WMMoving(var Message: TWMMOVING);
var
  i: integer;
begin
  for i := 0 to ComponentCount - 1 do
  begin
    if Components[i].ClassName <> 'TForm' then
      continue; // Si los hijos de TFormMain no son TFORM
    with Components[i] as TForm do
      SetWindowPos(Handle, HWND_TOPMOST,
                   Message.DragRect.Left + Left - self.Left,
                   Message.DragRect.Top + Top - self.Top,
                   0, 0, SWP_NOSIZE or SWP_NOACTIVATE or SWP_NOZORDER);
  end;
end;

Con mi codigo se ve (al ojo) el desplazamiento de las ventanas hijas sobre el formulario principal.
Código Delphi [-]
    procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message WM_WINDOWPOSCHANGING;

procedure TFormMain.WMWindowPosChanging(var Message: TWMWindowPosChanging);
var
  i, t: word;
begin
  // Mover objetos DCx junto con la ventana principal
  t := Length(DCx);
  if t = 0 then
    Exit;
  for i := 0 to t - 1 do
  begin
    if DCx[i] = nil then
      Continue;
    DCx[i].Forma.Top := Self.Top + PxArriba + DCx[i].Top;
    DCx[i].Forma.Left := Self.Left + PxBorde + DCx[i].Left;
  end;
  inherited;
end;

Lo que no he sabido hacer es como implementar
Código Delphi [-]
procedure WMMoving(var Message: TWMMOVING); message WM_MOVING;
en las ventanas hijas por que se crean "on the fly y sin forma", pero es que ademas como controlo las pulsaciones del raton entonces aprovecho para mover las ventanas hijas.
Código Delphi [-]
  Forma := TForm.CreateNew(FormularioPadre, 0);
  Forma.Position := poDesigned;
  Forma.BorderStyle := bsNone;
  Forma.Left := FormularioPadre.Left + PxBorde + Left;
  Forma.Top := FormularioPadre.Top + PxArriba + Top;
  Forma.Color := clHotLight;
  Forma.Visible := Visible;
  Forma.AlphaBlend := True;
  Forma.AlphaBlendValue := Opacidad;
  Forma.ShowHint := True;
  Forma.Hint := 'Left-Click y arrastre para mover';
  Forma.OnMouseDown := LedOnMouseDown;
  Forma.OnMouseMove := LedOnMouseMove;
  Forma.OnMouseUp := LedOnMouseUp;

asi que sigo usando las que me van bien
Código Delphi [-]
procedure TcapturadorDCx.LedOnMouseDown(Sender: TObject; Button: TMouseButton;
                                        Shift: TShiftState; X, Y: Integer);
begin
  // Capturar posicion inicial del ratón al comenzar a mover
  oldLeft := X;
  oldTop := Y;
  // Solo si es Shape LedOn
  if Sender is TForm then
    Exit;
  // Cambiar estado a icono o detalle
  if Button = mbRight then
  begin
    if Icono = True then
      SetIcono(False)
    else
      SetIcono(True);
    Exit;
  end;
  // comprobar si ha pulsado doble-click
  if ssDouble in Shift = False then
    Exit;
  // Encender o Apagar el capturador
  if DCx = nil then
    ActivaDCx // si no ha sido activado
  else
    if DCx.abierto = True then
      DesactivaDCx
    else
      if (DCx.conectando = False) and (Conectando = False) then
        ActivaDCx; // si las tarea DCx y el objeto TcapturadorDCx estan parados
end;

procedure TcapturadorDCx.LedOnMouseMove(Sender: TObject; Shift: TShiftState;
                                        X, Y: Integer);
var
  nX, nY, nLeft, nTop: integer;
begin
  if ssLeft in Shift = False then
    Exit;
  // Mover la posicion del objeto
  if X < oldLeft then
  begin
    nX := oldLeft - X;
    nLeft := Forma.Left - nX;
  end
  else
  begin
    nX := X - oldLeft;
    nLeft := Forma.Left + nX;
  end;
  if Y < oldTop then
  begin
    nY := oldTop - Y;
    nTop := Forma.Top - nY;
  end
  else
  begin
    nY := Y - oldTop;
    nTop := Forma.Top + nY;
  end;
  // Controlar los limites
  // Izquierda
  if nLeft < (FormularioPadre.Left + PxBorde) then
    nLeft := FormularioPadre.Left + PxBorde;
  // Derecha
  if (nLeft + Forma.Width) > (FormularioPadre.Left + FormularioPadre.Width - PxBorde) then
    nLeft := (FormularioPadre.Left + FormularioPadre.Width) - Forma.Width - PxBorde;
  // Arriba
  if nTop < (FormularioPadre.Top + PxArriba) then
    nTop := FormularioPadre.Top + PxArriba;
  // Abajo
  if (nTop + Forma.Height) > (FormularioPadre.Top + FormularioPadre.Height - PxAbajo) then
    nTop := (FormularioPadre.Top + FormularioPadre.Height) - Forma.Height - PxAbajo;
  // reposicionar objecto
  Forma.Left := nLeft;
  Forma.Top := nTop;
end;

procedure TcapturadorDCx.LedOnMouseUp(Sender: TObject; Button: TMouseButton;
                                      Shift: TShiftState; X, Y: Integer);
begin
  Left := Forma.Left - (FormularioPadre.Left + PxBorde);
  Top := Forma.Top - (FormularioPadre.Top + PxArriba);
  Movido(Sender);
end;

Por tanto, de momento, me quedo con el tuyo en el formulario padre y con el mio en el formulario hijo en tiempo de ejecucion.

__________________
Disfruta de la vida ahora, vas a estar muerto mucho tiempo.
Responder Con Cita