Why are TGeneric and TGeneric incompatible types?

TDataProviderThread is a descendant of TThreadBase, but TThreadBaseList<TDataProviderThread> is not a descendant of TThreadBaseList<TThreadBase>. That’s not inheritance, it’s called covariance, and though it seems intuitively like the same thing, it isn’t and it has to be supported separately. At the moment, Delphi doesn’t support it, though hopefully it will in a future release. Here’s the … Read more

TThread.resume is deprecated in Delphi-2010 what should be used in place?

Charles if do you read the code of TThread class , do you find the answer. TThread = class private type .. .. .. public constructor Create(CreateSuspended: Boolean); destructor Destroy; override; procedure AfterConstruction; override; // This function is not intended to be used for thread synchronization. procedure Resume; deprecated; // Use Start after creating a … Read more

Selecting a directory with TOpenDialog

You can use the TFileOpenDialog (on Vista+): with TFileOpenDialog.Create(nil) do try Options := [fdoPickFolders]; if Execute then ShowMessage(FileName); finally Free; end; Personally, I always use the TFileOpenDialog on Vista+ and fallback using the SelectDirectory (the good one!) on XP, like this: if Win32MajorVersion >= 6 then with TFileOpenDialog.Create(nil) do try Title := ‘Select Directory’; Options … Read more

Convert Record to Serialized Form Data for sending via HTTP

Ok, here is a boilerplate solution which can be adapted for your specific serialization or other use as well. A record, TSerializer, does all the serialization job and the result is stored in a string list. To use it, call method Serialize(‘state’, TValue.From(state),sList); from a TSerializer instance. You can add most types that fit into … Read more