Ver Mensaje Individual
  #5  
Antiguo 10-12-2003
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.964
Reputación: 29
delphi.com.ar Va camino a la fama
Talking

Una curiosidad: Si una variable de objeto es nil y utilizamos algunos método o propiedades de este objeto, sobre todo lo referente a mensajes de Windows, no se produce un access violation, en el caso que quede apuntado a una dirección inválida si sucede.
Código:
Var
  MyEdit : TEdit;
begin
  MyEdit := Nil;
  ShowMessage( MyEdit.Text );
He preguntado sobre esto a Borland, y un tercero me respondió:
Cita:
It's a feature!
Such mistakes results normaly in AV and in this case in mal function.
With pascal we(!) have to write code that prevents us for this mistakes.

MyEdit.Text results in:

function TControl.Perform(Msg: Cardinal; WParam, LParam: Longint): Longint;
var
Message: TMessage;
begin
Message.Msg := Msg;
Message.WParam := WParam;
Message.LParam := LParam;
Message.Result := 0;
if Self <> nil then WindowProc(Message);
Result := Message.Result;
end;

Sorry, but it's not so nice that you fill QC with such senceless information.
Probably start a diskussion in borland.public.delphi.language.objectpascal
for testing every access to any TObject for a valid address. See what the community will say about this.
Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita