Ver Mensaje Individual
  #19  
Antiguo 08-06-2007
Avatar de Al González
[Al González] Al González is offline
In .pas since 1991
 
Registrado: may 2003
Posts: 5.604
Reputación: 30
Al González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en brutoAl González Es un diamante en bruto
Smile Viendo el código...

¡Hola a todos!

Alfredo:

Le eché un vistazo al código fuente del componente. Veo que es en el método mensaje TAdCustomTerminal.ApwTermStuff donde se hace el guardado al archivo:
Código Delphi [-]
procedure TAdCustomTerminal.ApwTermStuff(var Msg : TMessage);
var
  DataLen  : integer;
  DataPtr  : pointer;
  PaintRgn : HRGN;
begin
  {this message is sent by the tmTriggerAvail, and the WriteChar/
   WriteString methods; note that if there are two or more
   APW_TERMSTUFF messages in the message queue, the first one to be
   accepted will clear the byte queue, so the others need to take
   account of the fact that there may be no data}

  DataLen := TaaByteQueue(FByteQueue).Count;
  if (DataLen > 0) then begin
    DataPtr := TaaByteQueue(FByteQueue).Peek(DataLen);

    {if we are capturing, save the data to file}
    if (Capture = cmOn) then begin
      if (FCaptureStream <> nil) then
        FCaptureStream.Write(DataPtr^, DataLen);
    end;
...
FCaptureStream.Write(DataPtr^, DataLen);


Al observar este código, lo primero que se me ocurrió fue que podría crearse un componente derivado TAGAGAdTerminal, agregando un evento OnCapture (que sinceramente extraño que no venga ya incluido). Esto con el objetivo de acceder al campo FByteQueue o al campo FCaptureStream, pero desgraciadamente tanto uno como el otro están declarados en la sección privada de la clase TAdCustomTerminal (hace tiempo que evito usar secciones Private; suele resultar algo desalentador a otros programadores bibliotecarios cuando desean crear clases derivadas).

Aún así, la solución es viable. Podrías derivar una nueva clase de componente, redefiniendo el método mensaje ApwTermStuff, pero tendrías que agregarla en la misma unidad (ADTrmEmu.pas) para acceder "decentemente" al campo privado FByteQueue.

Una solución más fácil es modificar directamente el código de ese método y leer la variable DataPtr para el propósito buscado.

TAdCustomTerminal.ApwTermStuff ofrece una ventana a la solución, pero es muy probable que, examinando el código con mayor detalle, encontremos alternativas. ¿Cómo ven la situación? ¿Por dónde nos vamos?

Un abrazo terminal.

Al González.
Responder Con Cita