Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   API de Windows (https://www.clubdelphi.com/foros/forumdisplay.php?f=7)
-   -   Boton Windows xp (https://www.clubdelphi.com/foros/showthread.php?t=15598)

Onti 28-10-2004 16:49:07

Boton Windows xp
 
Hola Amigos:

Como puedo realizar una funcion similar al boton "ir al escritorio" que viene con Windows xp y generalmente se encuentra en la barra de tareas de windows.


Gracias.

Neftali [Germán.Estévez] 28-10-2004 17:45:58

Personalmente no lo he probado y no me gusta mucho cómo está hecho, pero mientras no tengas nada mejor puedes probar éste código:

Código Delphi [-]
  procedure MinimizeAll;
  Begin
    {  + 'M' minimizes all windows, +'M'
      restores them }
    keybd_event( VK_LWIN, MapvirtualKey( VK_LWIN, 0), 0, 0 );
    keybd_event( Ord('M'), MapvirtualKey( Ord('M'), 0), 0, 0 );
    keybd_event( Ord('M'), MapvirtualKey( Ord('M'), 0), KEYEVENTF_KEYUP, 0 );
    keybd_event( VK_LWIN, MapvirtualKey( VK_LWIN, 0), KEYEVENTF_KEYUP,  0 );
  end;

Neftali [Germán.Estévez] 28-10-2004 17:57:06

Versión mejorada ;-)
 
Éste sí me gusta más...

(1) Coloca en tu form un botón
(2) Añade la unit ComObj al uses
(3) Añade las dos definiciones siguientes al private.

Código Delphi [-]
    procedure Minimize;
    procedure Restore;

(4) La implementación de los dos procedimientos es la siguiente:

Código Delphi [-]
procedure TForm1.Minimize;
var
  Shell : OleVariant;
begin
  Shell := CreateOleObject('Shell.Application') ;
  Shell.MinimizeAll;
  Shell := VarNull;
end;
procedure TForm1.Restore;
var
  Shell : OleVariant;
begin
  Shell := CreateOleObject('Shell.Application') ;
  Shell.UndoMinimizeAll;
  Shell := VarNull;
  // Delay for 100ms to allow all other windows to restore then
  // set this one to foreground.
  Sleep(100);
  SetForegroundWIndow(Self.Handle);
end; {Restore}

(5) Y por último en el evento del botón coloca lo siguiente:

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
  case Button1.Tag of
  0:
    begin
      Minimize;
      Button1.Tag := 1;
    end;
  1:
    begin
      Restore;
      Button1.Tag := 0;
    end;
  end;
end;

roman 28-10-2004 18:01:30

Cita:

Empezado por Neftali
Código Delphi [-]
{  + 'M' minimizes all windows, +'M'
restores them }

¡Ah! ¿Se refieren a ese botón? Quizá les sirva esto.

// Saludos

Onti 28-10-2004 21:15:38

Muchas gracias, ahora mismo hago la prueba


La franja horaria es GMT +2. Ahora son las 23:01:09.

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