difference between int* i and int *i

As far as C goes they both do the same thing. It is a matter of preference. int* i shows clearly that it is an int pointer type. int *i shows the fact that the asterisk only affects a single variable. So int *i, j and int* i, j would both create i as an … Read more

Published interface properties bug and workarounds

To summarize, the problem happens only with published interface properties that have a getter method, and the property points to component on another form/module (and that form/module is not recreated yet). In such case restoring form DFM causes an AV. I’m pretty sure the bug is in the ASM code in GetOrdProp, but it’s beyond … Read more

Serious FireMonkey performance issues when there are a lot of controls at screen

I tried your code, it takes 00:10:439 on my PC on XE3 to fill screen with cells. By disabling these lines: //ProgressBar.Value:= ProgressBar.Value + 1; //Caption:= ‘Elapsed time: ‘ + FormatDateTime(‘nn:ss:zzz’, Time – T) + // ‘ (min:sec:msec) Cells: ‘ + IntToStr(Trunc(ProgressBar.Value)); … //Application.ProcessMessages; This goes down to 00:00:106 (!). Updating visual controls (such as … Read more

What is the difference between the new TFileOpenDialog and the old TOpenDialog?

TOpenDialog executes TFileOpenDialog when the following conditions are met: the program is running under Vista (and up) UseLatestCommonDialogs is true (which is the default) no OnIncludeItem, OnClose or OnShow events are set So while still using TOpenDialog on your system you may likely end up automagically executing TFileOpenDialog in most cases, which explains why they … Read more

How do I sort a generic list using a custom comparer?

The Sort overload you should be using is this one: procedure Sort(const AComparer: IComparer<TMyRecord>); Now, you can create an IComparer<TMyRecord> by calling TComparer<TMyRecord>.Construct. Like this: var Comparison: TComparison<TMyRecord>; …. Comparison := function(const Left, Right: TMyRecord): Integer begin Result := Left.intVal-Right.intVal; end; List.Sort(TComparer<TMyRecord>.Construct(Comparison)); I’ve written the Comparison function as an anonymous method, but you could also … Read more

Why variables are declared as TStrings and created as TStringList?

TStrings is an abstract type that doesn’t have all methods implemented. TStringList is a descendant of TStrings and implements all functions. In your code, you could declare your variable also as TStringList. However e.g. on function definitions it makes sense to accept a TStrings parameter instead of a TStringList: procedure doSomething(lst: TStrings); This enables the … Read more