Quite a while ago, a co-worker asked how to get tot the Instance variable when using a with statement like this:
function TMyForm.ExecuteForm(FormClass: TFormClass): Integer;
begin
with FormClass.Create(self) do
try
Result := ShowModal;
finally
Free;
end;
end;
So I wrote the blog entry below when I started my blog last week, and set the published date to somewhere early May, a week that will be really busy.
Then I found out about the Stackoverflow question Reference object instance created using “with” in Delphi followed by the answer by user ‘Alexander‘ (a really smart Russian guy).
Enough coincidence to publish the blog article earlier than scheduled :-)
Before I explain why I really hate ‘with’, lets show what my co-worker wanted, and my solution: Read the rest of this entry »





