Daniel,
Cita:
Empezado por ecfisa
...había probado chequear el estado mediante un Timer. Pero adolece del defecto que no funciona si existe alguna otra ventana modal abierta...
|
Probé lo que comentas en el
Msg #12 en el siguiente código,
funcionado correctamente en todos los casos de prueba:
Código Delphi
[-]
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
const
WM_AFTER_SHOW = WM_USER + 301;
type
TForm1 = class(TForm)
Timer1: TTimer;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
procedure WmAfterShow(var Msg: TMessage); message WM_AFTER_SHOW;
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
FormStyle := fsNormal;
end;
procedure TForm1.WmAfterShow(var Msg: TMessage);
begin
ShowMessage('Presiona WIN + D ...')
end;
procedure TForm1.Timer1Timer;
begin
if not Application.Active then
Application.Restore;
if WindowState = wsMinimized then
WindowState := wsNormal;
if not Visible then
Visible := True;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
PostMessage(Self.Handle, WM_AFTER_SHOW,0,0);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
MsgDialog : TForm;
MsgUser : String;
begin
MsgUser := 'Mensaje al Usuario';
MsgDialog := CreateMessageDialog(MsgUser, mtWarning, [mbOk]) ;
MsgDialog.FormStyle := fsStayOnTop;
MsgDialog.ShowModal;
ShowMessage(MsgUser);
MessageDlg(MsgUser,mtInformation,[mbOK],0);
Application.MessageBox(PChar(MsgUser), PChar(Application.Title), MB_OK + MB_ICONINFORMATION);
MessageBox(Handle, PChar(MsgUser), PChar(Application.Title), MB_OK + MB_ICONINFORMATION);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
PostMessage(Self.Handle, WM_AFTER_SHOW,0,0);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
SendMessage(Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
PostMessage(Handle, WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
Perform(WM_SYSCOMMAND, SC_MINIMIZE, 0);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
ShowWindow(Handle, SW_MINIMIZE);
end;
end.
El código anterior en
Delphi 7 sobre Windows 7 Professional x32,
impide en todos los casos señalados en el ejemplo que el formulario Form1 sea minimizado.
Pregunto : ¿Que SO tienes instalado?, quizás lo que mencionas este relacionado a la versión de Windows
Saludos
Nelson.