Ver Mensaje Individual
  #13  
Antiguo 16-11-2017
REHome REHome is offline
Miembro
 
Registrado: jul 2003
Ubicación: España
Posts: 454
Reputación: 21
REHome Va por buen camino
Buenas:

@Casimiro Notevi No hace falta poner ningún Sleep para que me de tiempo, no aparece ese mensaje. El tiempo te lo da lo que dure en abrir la bandeja.

Por cierto, ya funciona con Application.ProcessMessages; que puso nuestro compañero @ElDioni.

Dejo el código Delphi completo por si alguien lo pueda necesitar.
Código:
unit Lector_bandeja;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, MMSystem;

  // No olvidar añadir en uses MMSystem arriba.

type
  TForm1 = class(TForm)
    RadioGroup_Bandeja: TRadioGroup;
    Button_Abrir: TButton;
    Button_Cerrar: TButton;
    Label_Mensaje: TLabel;
    procedure Button_AbrirClick(Sender: TObject);
    procedure Button_CerrarClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure OpenCd(AOpen:Boolean);
const
    DoPlay : array[Boolean] of string = ('Set cdaudio door closed wait',
         'Set cdaudio door open wait');
var
   MyError       : LongInt;
   MyErrorString : array[0..MAXERRORLENGTH - 1] of char;
begin
   MyError := mciSendString(pChar(DoPlay[AOpen]), nil, 0, 0);
   if MyError <> 0 then
   begin
     MciGetErrorString(MyError,MyErrorString,MAXERRORLENGTH - 1);
     Showmessage(MyErrorString);
     Exit;
   end;
end;
procedure TForm1.Button_AbrirClick(Sender: TObject);
begin
    Label_Mensaje.Caption := 'Abriendo...';
    Application.ProcessMessages;
    OpenCd(TRUE);
    Label_Mensaje.Caption := 'Abierto.';
end;

procedure TForm1.Button_CerrarClick(Sender: TObject);
begin
    Label_Mensaje.Caption := 'Cerrando...';
    Application.ProcessMessages;
    OpenCd(FALSE);
    Label_Mensaje.Caption := 'Cerrado.';
end;

end.
Muchas gracias a tod@s.
__________________
http://electronica-pic.blogspot.com....n-arduino.html Manuales de electrónica general, PIC y Arduino.

Última edición por REHome fecha: 16-11-2017 a las 20:34:59.
Responder Con Cita