noreply@blogger.com (Rudy Velthuis) | 2018-03-09 17:21
eolconv An up-to-date version of this and other files can be found in my CommandLineTools project on GitHub. On Stack Overflow and in the Embarcadero forums I regularly see people ask how to convert a file with Unix line endings to Windows line endings, or vice versa. The usual advice is to load the file into Notepad++ and to save it with the desired line ending format. But Delphi can do this too, either using AdjustLineBreaks or using a TStringList. That is why I wrote this simple command line tool. The actual conversion is extremely simple: Load the file into…
noreply@blogger.com (Rudy Velthuis) | 2018-03-04 19:51
I guess everyone who had to maintain one package for several different versions of Delphi had wished this was possible to do with a single package source. The alternative is to have different set of .dpk and .dproj files, each with a different name or suffix, for each version you want to cover. Some, including me, devised a "clever" include file that set a different {$LIBSUFFIX } for each version. So did I, but every simple change to the package would remove the {$INCLUDE 'LibSuffixes.inc'} I put in the .dpk file and replace it with something like {$LIBSUFFIX '230'} if…
noreply@blogger.com (Rudy Velthuis) | 2018-02-01 18:02
The problem In a recent blog post, Dalija Prasnikar talks about how hard it would be to optimize ARC code, because most ARC object references will be passed by value, but not as const. Passing as const would eliminate the need for an implicit __ObjAddRef() call each time the object is passed (and an __ObjRelease() call when the routine with the parameter ends). OK, ARC (automatic reference counting) has been used for many types already, most of all strings, dynamic arrays and interfaces. Code passing strings and dynarrays is generally optimized already, by specifying such parameters as const. There are…
noreply@blogger.com (Rudy Velthuis) | 2018-01-22 12:51
In versions of Delphi before 10.1 Berlin, it was possible to access private members and private methods of a class simply by defining a class helper for it and accessing these private items in its methods. But that it was so easy to access private members undermined the basic OO principles of information hiding and encapsulation. That is why this loophole (which could be considered a bug) was closed in Delphi 10.1 Berlin. But there was a lot of howling about this, because it was so easy and so convenient to have access to everything, even to other classes' "private…
noreply@blogger.com (Rudy Velthuis) | 2018-01-15 20:48
In a recent debate I had it was said that strings in the Win64 runtime are too slow to be useful. That is, in my opinion, a gross exaggeration. It is true that the Win32 runtime library (RTL) has benefited a lot from the work of the FastCode project, usually with routines in extremely clever assembler. For all other platforms, often the routines are in plain Object Pascal, so no assembler is being used. Also, far fewer routines have been replaced by clever implementations. One very obvious example of this is the Pos function, which searches if a certain string…
| 2017-12-27 02:22
Simple example of converting a window handle (HWND data type) to a string in a Delphi VCL program cardinal(vMyWindowHandle).ToString This uses the WinApi.Windows unit Example Show the window handle of the foreground window procedure TForm1.Button1Click(Sender: TObject); var vMyWindowHandle : HWND; begin vMyWindowHandle := GetForegroundWindow(); // get top most window ShowMessage ('Window handle is […]
| 2017-12-17 04:35
When writing a Delphi TTimer event, I often disable the timer and re-enable it at the end of the event. If you dont do this, the OnTimer event could fire again before you have finished processing it. procedure TForm1.Timer1Timer(Sender: TObject); begin Timer1.enabled := FALSE; // disable the timer so it wont fire while we […]
| 2017-11-23 12:09
Download my free software to add hotkeys to the Delphi IDE to increase and decrease the font size in the code editor. Update – Delphi 10.4 Delphi 10.4 has added a font zoom slider at the bottom of the screen Hot Keys My software uses these hot keys to change the front size in any […]
Page 130 of 144