Ver Mensaje Individual
  #6  
Antiguo 28-06-2014
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 23
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Neg90,

Cita:
Empezado por Neg90
...hay algún componente dentro de Delphi, que sirva para mostrar un mensaje durante unos segundos...
Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure DialogTimer(Sender: TObject);
    function  MsgDialog(const DlgCaption, DlgMsg: String;
                        DlgType: TMsgDlgType;
                        DlgButtons: TMsgDlgButtons;
                        DlgInterval : Integer ) : Boolean;

    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DialogTimer(Sender: TObject);
begin

   if NOT (Sender is TTimer) then Exit;

   if (Sender as TTimer).Owner is TForm then
   with (Sender as TTimer).Owner as TForm do
   begin
      ModalResult := mrCancel
   end;

end;

function TForm1.MsgDialog(const DlgCaption, DlgMsg: String;
                          DlgType: TMsgDlgType;
                          DlgButtons: TMsgDlgButtons;
                          DlgInterval : Integer ) : Boolean;
var
   AMsgDialog : TForm;
   ATimer : TTimer;

begin

   try

      AMsgDialog := CreateMessageDialog(DlgMsg, DlgType, DlgButtons);
      ATimer := TTimer.Create(AMsgDialog);

      with AMsgDialog do
      try

         Caption := DlgCaption;
         Height := 100;

         with ATimer do
         begin
            Interval := DlgInterval;
            OnTimer := DialogTimer;
         end;

         Beep;
         ShowModal;

         Result := True;

      finally

         ATimer.OnTimer := nil;
         Free;

      end;

   except

      Result := False;

   end;

end;

procedure TForm1.Button1Click(Sender: TObject);
var
   Caption, Msg : String;
begin
   Caption := 'Información de Progreso';
   Msg := 'La Operación Fue Completada de Forma Satisfactoria';
   MsgDialog(Caption,Msg,mtInformation,[],2000); // El Msg se visualiza por 2 segundos.
end;

end.
El código anterior en Delphi 7 bajo Windows 7 Professional x32, permite configurar los parámetros de visualización de un mensaje incluyendo su tiempo de exposición.

Nota: En lo personal pienso que este tipo de mensajes no es conveniente para los usuarios dado que tienden a ignorarlos o simplemente no los ven.

Espero sea útil

Nelson.

Última edición por nlsgarcia fecha: 28-06-2014 a las 06:05:34.
Responder Con Cita