Ver Mensaje Individual
  #4  
Antiguo 29-12-2012
_CALI _CALI is offline
Miembro
 
Registrado: mar 2008
Posts: 99
Reputación: 17
_CALI Va por buen camino
Smile

Gracias por tu colaboración ecfisa y a los demás tambien,
Talvez no fui muy claro, pero lo que quiero es que el panel se muestre siempre el ultimo sitio del Z orden, asi hayan formularios hijos abiertos
Aquí les dejo la solucion que escribi:

la definición del panel esta en el formulario padre,
primero que nada hay que colocar un panel en el formulario padre y luego sobre el panel cualquier control
Código Delphi [-]
type
  TPanel = class(Vcl.ExtCtrls.TPanel)
  protected
   procedure Loaded; override;
   procedure WMWindowPosChanging(var Msg: TWMWindowPosChanging);
   message WM_WINDOWPOSCHANGING;
 end;
 
type
 TMain = class(TForm)
  ...
 
var
  Main: TMain;
 
implementation
 
procedure TPanel.Loaded;
begin
  inherited;
  Windows.SetParent(Handle, Main.ClientHandle);
end;
procedure TPanel.WMWindowPosChanging(var Msg: TWMWindowPosChanging);
begin
  if (Msg.WindowPos^.flags and SWP_NOZORDER) = 0 then
      Msg.WindowPos^.hwndInsertAfter := HWND_BOTTOM;
 inherited;
end;


luego en el formulario hijo...

Código Delphi [-]
const
 WM_GETACTIVEFORM = WM_USER + 100;
 
type
 TChild = class(TForm)
...
private
procedure WMWindowPosChanging(var Msg: TWMWindowPosChanging);
   message WM_WINDOWPOSCHANGING;
procedure WMGetActiveForm(var Msg: TMessage); 
   message WM_GETACTIVEFORM;

var
  Child: TChild;
 
implementation
 
procedure TChild.WMGetActiveForm(var Msg: TMessage);
var i: integer;
begin
 for i := 0 to MDIChildCount - 1 do
  begin
   if MDIChildren[i].WindowState <> wsMinimized then
      begin
      MDIChildren[i].BringToFront;
      Break;
      end;
  end;
end;
 
procedure TChild.WMWindowPosChanging(var Msg: TWMWindowPosChanging);
 begin 
 
       if Msg.windowpos^.hwndInsertAfter <> HWND_TOP  then
          begin
          Msg.windowpos^.hwndInsertAfter := HWND_TOP;
          PostMessage(Handle, WM_GETACTIVEFORM, 0, 0);
          end;

inherited;
end;

Manejando los mensajes WM_WINDOWPOSCHANGING del panel y el formulario hijo, se consige que el panel este siempre al fondo y otra cosa mas..

se dieron cuenta que cuando minimizan un formulario, este se queda como ActiveMDIChild?,
con un mensaje de ususario lo que hace es establecer el ActiveMDIChild del ultimo formulario activo al minimizarlo.


Saludos y Gracias denuevo !!!

Última edición por _CALI fecha: 29-12-2012 a las 04:08:43.
Responder Con Cita