procedure TForm1.Button1Click(Sender: TObject); var a: Integer; begin ShowMessage(IntToStr(Integer(a))); end; procedure TForm1.Button2Click(Sender: TObject); begin ShowMessage(IntToStr(Integer(Pointer(TButtonControl(Button1))))); end;
on my machine, this code generates the same message that the compiler uses ebx for variable a , and TButtonControl.WndProc uses ebx to save a pointer to Self (since EAX will be overwritten after calling the WinAPI function from TbuttonControl.WndProc), which is button1 , before calling the actual Button1Click handler. So alas, in Delphi 2007 the message text is too predictable.
[edit] You can see what happens inside the VCL when debugging, if you enable the Use debug DCUs option in the project compiler options Compiler-> Debugging-> Use debugging DCUs .
source share