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; 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
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
oldLeft := X;
oldTop := Y;
if Sender is TForm then
Exit;
if Button = mbRight then
begin
if Icono = True then
SetIcono(False)
else
SetIcono(True);
Exit;
end;
if ssDouble in Shift = False then
Exit;
if DCx = nil then
ActivaDCx else
if DCx.abierto = True then
DesactivaDCx
else
if (DCx.conectando = False) and (Conectando = False) then
ActivaDCx; 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;
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;
if nLeft < (FormularioPadre.Left + PxBorde) then
nLeft := FormularioPadre.Left + PxBorde;
if (nLeft + Forma.Width) > (FormularioPadre.Left + FormularioPadre.Width - PxBorde) then
nLeft := (FormularioPadre.Left + FormularioPadre.Width) - Forma.Width - PxBorde;
if nTop < (FormularioPadre.Top + PxArriba) then
nTop := FormularioPadre.Top + PxArriba;
if (nTop + Forma.Height) > (FormularioPadre.Top + FormularioPadre.Height - PxAbajo) then
nTop := (FormularioPadre.Top + FormularioPadre.Height) - Forma.Height - PxAbajo;
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.
