-
Content Count
2068 -
Joined
-
Last visited
-
Days Won
27
Everything posted by Attila Kovacs
-
Inch representation format in TEdit like controls
Attila Kovacs replied to Cristian Peța's topic in General Help
There must be a bug in Delphi as "\/" does not make a literal from "/" but instead converts it to the system's date separator. Buhh. Anyway, what if the user just want to enter 12"? -
Micro optimization: Split strings
Attila Kovacs replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
@Fr0sT.Brutal It won't be compatible with other systems. Also, .Split() accepts Option flags, there could be an IgnoreLastEmpty for that case. -
@balabuev Could you figure it out what is happening there? It's not clear for me based on that workaround.
-
Micro optimization: Split strings
Attila Kovacs replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Yet again? 🙈 -
Micro optimization: Split strings
Attila Kovacs replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
interesting how Split() interpretations differ: //Delphi RTL sp := 'qq;ww;ee;'.Split([';']); // => ['qq', 'ww', 'ee'] // My test case arr := Split('qq;ww;ee;'); // => ['qq', 'ww', 'ee', ''] This in python and in php returning also ['qq', 'ww', 'ee', ''], and so would I expect. -
there is a fat 26% discount on D until 28. Feb, so start testing!!! 😉
-
Sorry, I thought calling destructor TWinControl.Destroy; is equal to destroying a component. my bad
-
You can achieve the same with two TListView's on the same parent, like a TPanel, both having one node. There is something with FTempItem or I don't know, TSubItems' constructor and destructor is not called the same time (4/3), I have no more time for debugging and I don't want to see this code anymore. I can't believe that on a theme change you have to destroy and create a component 4 times in a row.
-
reproduced with Berlin U2
-
Micro optimization: Split strings
Attila Kovacs replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
@Fr0sT.Brutal cool, this also helped me to spot some bugs in my enum version. do you have a unit test for it? -
an MCVE would be nice as we could figure out which version are affected and also debug it instead of guessing
-
Do we know wich Delphi versions are affected?
-
XLS 2 XLSX
Attila Kovacs replied to DrShepard's topic in Algorithms, Data Structures and Class Design
Sorry, it's "--outdir", you can check the parameters with "--help". Yes, *nix style. That's why the "*.xls" also doesn't work. (<o> free software) You can also create a batch file with "for in" and call that. https://ask.libreoffice.org/en/question/253696/using-wildcards-for-windows-command-line-batch-convert/ -
Max string literal length = 255
Attila Kovacs replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
can we ban this clown @Lars Fosdal? -
Read and reapply design time properties to specific controls - runtime
Attila Kovacs replied to aehimself's topic in VCL
He also mentions that he is successfully hides/resizes/rearranges those components. That said, I can't see any problem to reset them. Also, I trust him fully that he knows what he is doing. -
Read and reapply design time properties to specific controls - runtime
Attila Kovacs replied to aehimself's topic in VCL
@balabuev TWinControl.DisableAlign may help there -
Read and reapply design time properties to specific controls - runtime
Attila Kovacs replied to aehimself's topic in VCL
If there are some non-standard written controls which has to be restored, yes, you are right, it would need it's reader. On standard controls you can skip the data you don't need or you don't know. We can't see this from here. Nor the actual software to be able to decide which would be less effort, storing local the initial values or reading the dfm. I wanted to show him how to read the resources by its classtypes and read some properties, which he asked. -
Read and reapply design time properties to specific controls - runtime
Attila Kovacs replied to aehimself's topic in VCL
Re-read with TReader -> yes, see my previous comment Re-apply with TReader -> no, but you can reapply it by updating the corresponding properties by yourself -
Native Svg parsing and painting in Windows
Attila Kovacs replied to pyscripter's topic in RTL and Delphi Object Pascal
I did not feel the need to get PowerToys' preview criticized. It has nothing to do with the language it's written in. It's all about preferences. No. As I'm preparing the images for production and then it gets into a separate directory, and depending on the selected theme, dark or light, the colors in the SVG's are adjusted for all icons automatically on theme change. We sure not doing the same job. -
Native Svg parsing and painting in Windows
Attila Kovacs replied to pyscripter's topic in RTL and Delphi Object Pascal
<o> There is no thumbnail if you are in list or detail mode and it makes no sense to have the preview pane turned on if you are in icon-list mode and you can see the thumbnails. I understand that you like to turn the windows explorer into an full armed SVG workshop, I'm just saying that sometimes less is more. And it's definitely not slower. At least not on the usual SVG context. I admit that the white background could be a showstopper on dark themes, but this is a subject for a separate thread. Dark theme with bright text is very very bad for the eyes. -
Native Svg parsing and painting in Windows
Attila Kovacs replied to pyscripter's topic in RTL and Delphi Object Pascal
Really? I find it faster and more pleasant. Also it does not create a flashing parented form/frame + editor etc. on the preview pane every time a file is selected. Minimalist? What should be on an svg preview pane except the image itself? -
Read and reapply design time properties to specific controls - runtime
Attila Kovacs replied to aehimself's topic in VCL
I think this is what you need, you just have to adjust it a bit. // search in dfm resources by Attila Kovacs unit DFMSearch; interface uses System.Classes, System.Generics.Collections; type TDFMSearch = class private FFormClasses: TList<string>; FResourceNames: TList<string>; FSearchDictionary: TDictionary<string, string>; function GetFormClasses(AClass: TClass): TList<string>; procedure BuildStrings(AResources: TList<string>); procedure EnumClasses(AClass: TClass); public function Find(const ASearchString: string): TList<string>; constructor Create(AClass: TClass); overload; constructor Create(AClassNames: TList<string>); overload; destructor Destroy; override; end; implementation uses Winapi.Windows, System.Rtti, System.SysUtils, System.StrUtils; function EnumResNames(Module: HMODULE; ResType, ResName: PChar; Obj: Pointer): integer; stdcall; var ds: TDFMSearch; begin ds := TDFMSearch(Obj); if ds.FFormClasses.IndexOf(string(ResName)) > -1 then ds.FResourceNames.Add(string(ResName)); Result := 1; end; function TDFMSearch.GetFormClasses(AClass: TClass): TList<string>; var cl: TClass; ctx: TRttiContext; types: TArray<TRttiType>; typ: TRttiType; begin Result := TList<string>.Create; ctx := TRttiContext.Create; types := ctx.GetTypes; for typ in types do begin if typ.TypeKind = tkClass then begin cl := typ.AsInstance.MetaclassType; if (cl <> AClass) and cl.InheritsFrom(AClass) then Result.Add(UpperCase(cl.ClassName)); end; end; end; procedure TDFMSearch.BuildStrings(AResources: TList<string>); var i: integer; Flags: TFilerFlags; R: TReader; RS: Tresourcestream; vt: TValueType; Position: integer; text, PropName, CompClass, CompName, StrValue, ResStr: string; procedure ReadProperty; begin PropName := R.ReadStr; if ContainsText(PropName, 'caption') then begin vt := R.NextValue; case vt of vaWString, vaUTF8String: StrValue := R.ReadString; vaString, vaLString: StrValue := R.ReadString; else R.SkipValue; end; text := text + ' ' + StrValue; end else R.SkipValue; end; procedure ReadData; forward; procedure ReadComponent; begin R.ReadPrefix(Flags, Position); CompClass := R.ReadStr; CompName := R.ReadStr; ReadData; end; procedure ReadData; begin while not R.EndOfList do ReadProperty; R.ReadListEnd; while not R.EndOfList do ReadComponent; R.ReadListEnd; end; begin for i := 0 to AResources.Count - 1 do begin ResStr := UpperCase(AResources[i]); RS := Tresourcestream.Create(HInstance, ResStr, RT_RCDATA); try R := TReader.Create(RS, 4096); try text := ''; R.ReadSignature; ReadComponent; FSearchDictionary.AddOrSetValue(ResStr, text); finally R.Free; end; finally RS.Free; end; end; end; constructor TDFMSearch.Create(AClass: TClass); begin FSearchDictionary := TDictionary<string, string>.Create; EnumClasses(AClass); end; constructor TDFMSearch.Create(AClassNames: TList<string>); begin FSearchDictionary := TDictionary<string, string>.Create; BuildStrings(AClassNames); end; destructor TDFMSearch.Destroy; begin FSearchDictionary.Free; inherited; end; procedure TDFMSearch.EnumClasses(AClass: TClass); begin if not Assigned(FSearchDictionary) then begin FFormClasses := GetFormClasses(AClass); try FResourceNames := TList<string>.Create; try EnumResourceNames(HInstance, RT_RCDATA, @EnumResNames, NativeInt(Self)); BuildStrings(FResourceNames); finally FResourceNames.Free; end; finally FFormClasses.Free; end; end; end; function TDFMSearch.Find(const ASearchString: string): TList<string>; var i, j, slen: integer; sl: TArray<string>; pa: TPair<string, string>; begin Result := TList<string>.Create; sl := ASearchString.Split([' ']); slen := Length(sl); for pa in FSearchDictionary do begin j := 0; for i := 0 to High(sl) do begin if ContainsText(pa.Value, sl[i]) then inc(j); end; if j = slen then Result.Add(pa.Key); end; end; end. -
Read and reapply design time properties to specific controls - runtime
Attila Kovacs replied to aehimself's topic in VCL
There are the Explicit* properties in the dfm which are storing the design time positions and sizes. If you are not striping them. -
Micro optimization: Split strings
Attila Kovacs replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
My version is rather fun as some kind of pico-optimization. An on the fly enumerator! And also fast and low memory footprint. (And unidirectional 😉 TSplitEnumerator = class; TSplit = record private PValue: pointer; PDelimiter: pointer; public function GetEnumerator: TSplitEnumerator; class function Create(const AValue: string; const ADelimiter: string): TSplit; static; end; TSplitEnumerator = class private FValue: string; FDelimiter: string; FHasNext: boolean; FIndex: integer; FNIndex: integer; FLen: integer; FDelLen: integer; public constructor Create(const ASplit: TSplit); function MoveNext: boolean; {$IFNDEF DEBUG} inline; {$ENDIF} function GetCurrent: string; {$IFNDEF DEBUG} inline; {$ENDIF} property Current: string read GetCurrent; end; { TSplit } class function TSplit.Create(const AValue: string; const ADelimiter: string): TSplit; begin Result.PValue := pointer(AValue); Result.PDelimiter := pointer(ADelimiter); end; function TSplit.GetEnumerator: TSplitEnumerator; begin Result := TSplitEnumerator.Create(Self); end; { TSplitEnumerator } constructor TSplitEnumerator.Create(const ASplit: TSplit); begin FIndex := 1; pointer(FValue) := ASplit.PValue; pointer(FDelimiter) := ASplit.PDelimiter; FLen := Length(FValue); FDelLen := Length(FDelimiter); FNIndex := Pos(FDelimiter, FValue, FIndex); if (FNIndex = 0) then FNIndex := FIndex + FLen; FHasNext := (FLen > 0) and (FNIndex > 0); end; function TSplitEnumerator.GetCurrent: string; begin Result := Copy(FValue, FIndex, FNIndex - FIndex); if FNIndex + FDelLen < FLen then begin FIndex := FNIndex + FDelLen; FNIndex := Pos(FDelimiter, FValue, FIndex); if FNIndex = 0 then FNIndex := FLen + FDelLen; end else FHasNext := False; end; function TSplitEnumerator.MoveNext: boolean; begin Result := FHasNext; end; var s: string; begin for s in TSplit.Create(cShortStr, cDelimiter) do WriteLn(s); end; -
GExperts 1.3.18 experimental twm 2021-02-21 released
Attila Kovacs replied to dummzeuch's topic in GExperts
You let the genie out of the bottle 😜 🤐