-
Content Count
437 -
Joined
-
Last visited
-
Days Won
8
Kryvich last won the day on September 29 2019
Kryvich had the most liked content!
Community Reputation
174 ExcellentTechnical Information
-
Delphi-Version
Delphi Community Edition
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
Kryvich's Delphi Reporter - Simple reporting tool with templates in RTF, Word XML, Excel XML, HTML, plain text formats. For basic reports without images, charts, with a simple structure.
-
Change of column widths of ListField in TDBLookupComboBox
Kryvich replied to Squall_FF8's topic in VCL
@Squall_FF8 DataModule.LookupDatasetField1.DisplayWidth := 10; DataModule.LookupDatasetField2.DisplayWidth := 20; DataModule.LookupDatasetField3.DisplayWidth := 30; -
Change of column widths of ListField in TDBLookupComboBox
Kryvich replied to Squall_FF8's topic in VCL
You need to set the DisplayWidth property for the list fields of the list lookup dataset. AFAIK no. -
Tool for finding non-literal format strings
Kryvich replied to David Heffernan's topic in General Help
Definitely. But time is money. If Copilot can do it for you - why not? for Line in Lines do --> Line := Lines.Text; -
Tool for finding non-literal format strings
Kryvich replied to David Heffernan's topic in General Help
Copilot. The result: program FormatStringExtractor; uses SysUtils, Classes; function ContainsPlusBeforeComma(const S: string): Boolean; var PlusPos, CommaPos: Integer; begin PlusPos := Pos('+', S); CommaPos := Pos(',', S); Result := (PlusPos > 0) and (CommaPos > PlusPos); end; procedure ProcessFile(const FileName: string; LogFile: TStrings); var Lines: TStringList; Line, SubStr: string; StartPos, EndPos: Integer; begin Lines := TStringList.Create; try Lines.LoadFromFile(FileName); for Line in Lines do begin StartPos := Pos('Format(', Line); while StartPos > 0 do begin EndPos := PosEx('])', Line, StartPos); if EndPos > 0 then begin SubStr := Copy(Line, StartPos, EndPos - StartPos + 2); if ContainsPlusBeforeComma(SubStr) then LogFile.Add(SubStr); // Move the start position forward to find the next occurrence StartPos := PosEx('Format(', Line, EndPos + 2); end else Break; end; end; finally Lines.Free; end; end; procedure ProcessFolder(const Folder: string; LogFile: TStrings); var SearchRec: TSearchRec; FullPath: string; begin if FindFirst(Folder + '\*.*', faAnyFile, SearchRec) = 0 then begin repeat FullPath := Folder + '\' + SearchRec.Name; if (SearchRec.Attr and faDirectory) = faDirectory then begin if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then ProcessFolder(FullPath, LogFile); end else if ExtractFileExt(SearchRec.Name).ToLower = '.pas' then begin ProcessFile(FullPath, LogFile); end; until FindNext(SearchRec) <> 0; FindClose(SearchRec); end; end; var Folder: string; LogFile: TStringList; begin Write('Enter folder path to scan: '); ReadLn(Folder); LogFile := TStringList.Create; try ProcessFolder(Folder, LogFile); LogFile.SaveToFile('format.log'); WriteLn('Strings saved to format.log'); finally LogFile.Free; end; end. -
Can you please elaborate this? Maybe a short article on this topic. P.S. I've noticed that there have been several interesting Delphi projects from Brazilian developers lately. Skia for Delphi, D2Bridge Framework are the most notable.
-
Multiline strings '''...''' were a very nice addition to the language. Still waiting for constructions like case string1 of 'aaa':... DoubleValue := Variant1 if not VarIsNull(Variant1) else 0.0;
-
There are three things you can watch forever: fire, water, and code improving. procedure TLinkMemo.CNCommand(var Message: TWMCommand); begin inherited; case Message.NotifyCode of EN_VSCROLL: SyncLink(True); EN_HSCROLL: SyncLink(False); end; end; procedure TLinkMemo.SyncLink(Vertical: Boolean); const BAR_FLAGS: array[Boolean] of Integer = (SB_HORZ, SB_VERT); MSGS: array[Boolean] of Cardinal = (WM_HSCROLL, WM_VSCROLL); var scrollInfo: TScrollInfo; begin if LinkedMemo = nil then Exit; var savedLink := LinkedMemo.LinkedMemo; try LinkedMemo.LinkedMemo := nil; scrollInfo.cbSize := SizeOf(scrollInfo); scrollInfo.fMask := SIF_POS; if GetScrollInfo(Handle, BAR_FLAGS[Vertical], scrollInfo) then LinkedMemo.Perform(MSGS[Vertical], MAKEWPARAM(SB_THUMBPOSITION, scrollInfo.nPos), 0); finally LinkedMemo.LinkedMemo := savedLink; end; end; procedure TLinkMemo.WMHScroll(var Message: TMessage); begin inherited; SyncLink(False); end; procedure TLinkMemo.WMVScroll(var Message: TMessage); begin inherited; SyncLink(True); end;
- 39 replies
-
- delphi xe7
- synchronize
-
(and 2 more)
Tagged with:
-
Delphi TOIOBE index lifted in May 2022?
Kryvich replied to wuwuxin's topic in RTL and Delphi Object Pascal
1. Python -- First appeared 20 February 1991; 34 years ago 2. C++ -- First appeared 1985; 40 years ago 3. Java -- First appeared May 23, 1995; 29 years ago 4. С -- First appeared 1972; 53 years ago ... 10. Delphi -- Initial release 1995 Attention! Dinosaurs have won prizes! -
@limelect How do you scroll horizontally? I know some programs allow this by holding the shift key down while you operate the scroll wheel. But in our case it doesn't work. I can scroll horizontally by dragging the bottom slider on the scroll bar, or by moving the cursor to the end of the line with the keys.
- 39 replies
-
- delphi xe7
- synchronize
-
(and 2 more)
Tagged with:
-
OK I checked my code on Windows 7 in VirtualBox. Works like a charm.
- 39 replies
-
- delphi xe7
- synchronize
-
(and 2 more)
Tagged with:
-
@limelect It's strange. Works fine for me on Windows 10. (Screencast attached). SyncScroll.mp4
- 39 replies
-
- delphi xe7
- synchronize
-
(and 2 more)
Tagged with:
-
OK, my take. unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TLinkMemo = class(TMemo) private FLinkedMemo: TLinkMemo; procedure SyncLink; protected procedure WndProc(var Message: TMessage); override; public property LinkedMemo: TLinkMemo read FLinkedMemo write FLinkedMemo; end; TMemo = class(TLinkMemo); TForm1 = class(TForm) Memo1: TMemo; Memo2: TMemo; procedure FormCreate(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.dfm} procedure TLinkMemo.WndProc(var Message: TMessage); begin inherited; if (LinkedMemo = nil) or not LinkedMemo.HandleAllocated then Exit; case Message.Msg of WM_HSCROLL, WM_VSCROLL, WM_KEYDOWN, WM_MOUSEFIRST..WM_MOUSELAST: SyncLink; end; end; procedure TLinkMemo.SyncLink; procedure UpdateScrollBar(BarFlag: Integer; Msg: Cardinal); var scrollInfo: TScrollInfo; begin scrollInfo.cbSize := SizeOf(scrollInfo); scrollInfo.fMask := SIF_POS; if GetScrollInfo(Handle, BarFlag, scrollInfo) then LinkedMemo.Perform(Msg, MAKEWPARAM(SB_THUMBPOSITION, scrollInfo.nPos), 0); end; var savedLink: TLinkMemo; begin savedLink := LinkedMemo.LinkedMemo; try LinkedMemo.LinkedMemo := nil; UpdateScrollBar(SB_HORZ, WM_HSCROLL); UpdateScrollBar(SB_VERT, WM_VSCROLL); finally LinkedMemo.LinkedMemo := savedLink; end; end; procedure TForm1.FormCreate(Sender: TObject); begin Memo1.LinkedMemo := Memo2; Memo2.LinkedMemo := Memo1; end; end.
- 39 replies
-
- delphi xe7
- synchronize
-
(and 2 more)
Tagged with:
-
@limelect I guess you've over-engineered it a bit. @Uwe Raabe gave a great variant, it just needs a bit of tweaking. unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TLinkMemo = class(TMemo) private FLinkedMemo: TLinkMemo; procedure WMVScroll(var Message: TMessage); message WM_VSCROLL; procedure WMHScroll(var Message: TMessage); message WM_HSCROLL; procedure CNCommand(var Message: TWMCommand); message CN_COMMAND; procedure SyncLink; public property LinkedMemo: TLinkMemo read FLinkedMemo write FLinkedMemo; end; TMemo = class(TLinkMemo); TForm1 = class(TForm) Memo1: TMemo; Memo2: TMemo; procedure FormCreate(Sender: TObject); private public end; var Form1: TForm1; implementation {$R *.dfm} procedure TLinkMemo.SyncLink; var savedLink: TLinkMemo; myLine, linkLine: Integer; begin if LinkedMemo = nil then Exit; savedLink := LinkedMemo.LinkedMemo; try LinkedMemo.LinkedMemo := nil; LinkedMemo.CaretPos := CaretPos; LinkedMemo.Perform(EM_SCROLLCARET, 0, 0); myLine := Perform(EM_GETFIRSTVISIBLELINE, 0, 0); linkLine := LinkedMemo.Perform(EM_GETFIRSTVISIBLELINE, 0, 0); if myLine <> linkLine then LinkedMemo.Perform(EM_LINESCROLL, 0, myLine - linkLine); finally LinkedMemo.LinkedMemo := savedLink; end; end; procedure TLinkMemo.CNCommand(var Message: TWMCommand); begin inherited; if (Message.NotifyCode = EN_VSCROLL) or (Message.NotifyCode = EN_HSCROLL) then SyncLink; end; procedure TLinkMemo.WMVScroll(var Message: TMessage); begin inherited; SyncLink; end; procedure TLinkMemo.WMHScroll(var Message: TMessage); begin inherited; SyncLink; end; procedure TForm1.FormCreate(Sender: TObject); begin Memo1.LinkedMemo := Memo2; Memo2.LinkedMemo := Memo1; end; end.
- 39 replies
-
- delphi xe7
- synchronize
-
(and 2 more)
Tagged with:
-
@Uwe Raabe I hope the original author (notme) of the snippet has already done this. I've posted it here as a curious fact for those interested (like me). I haven't encountered any internal compiler errors in Delphi in recent years. Although, perhaps this bug has already been fixed in 12.2. (I have 12.1 CE).