How to correctly write Try..Finally..Except statements?

You just need two try/finally blocks: Screen.Cursor:= crHourGlass; try Obj:= TSomeObject.Create; try // do something finally Obj.Free; end; finally Screen.Cursor:= crDefault; end; The guideline to follow is that you should use finally rather than except for protecting resources. As you have observed, if you attempt to do it with except then you are forced to … Read more

How to free a generic TList?

Executive summary MyList.Free is sufficient. Detailed answer The TList<T> generic container owns its contents. When you free the container, the contents are also disposed of. Now, if T is an unmanaged reference, either a pointer or a class, then the list owns the reference. It does not own that which the reference refers to. So … Read more

What does `at ReturnAddress` mean in Delphi?

ReturnAddress is the address to which VerifyWrite would have returned when finished. Raise Exception.Create… at ReturnAddress means that when the exception dialog is displayed, it would indicate the address of the exception as being at ReturnAddress. In other words, the exception message would read Exception <whatever> raised at <ReturnAddress>: <Exception Message>. Here is an excerpt … Read more

Form is hidden behind other forms when ShowModal is called

You didn’t mention which version of Delphi… Newer Delphi versions have added two new properties to TCustomForm: PopupMode and PopupParent. Setting PopupParent of your modal dialog to the form that’s creating that dialog makes sure that the child form stays on top of it’s parent. It usually fixes the problem you’re describing. I think this … Read more

Annotating Methods in Delphi?

The feature is named XML Documentation Comments and is documented here. It appears to have been modelled closely on the equivalent .net feature so you should be right at home with it. The documentation contains this example: /// <summary> Removes the specified item from the collection /// </summary> /// <param name=”Item”>The item to remove /// … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)