Delphi | A simple mechanism for staking and claims | Cryptography library
kandi X-RAY | Delphi Summary
kandi X-RAY | Delphi Summary
A simple mechanism for staking and claims.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Delphi
Delphi Key Features
Delphi Examples and Code Snippets
Community Discussions
Trending Discussions on Delphi
QUESTION
I recently migrate to Delphi 11.0 this line 'Zip.CopyFrom(Source, 0); generate 'error 'Invalid ZStream operation'
...ANSWER
Answered 2022-Mar-22 at 05:38It appears to be fixed in 11.1
QUESTION
There are a few corrected issues in the VCL which had previous workarounds. Is there some method to identify that Delphi 11.1 is in fact installed and not 11.0 so the fix can be used rather than the workaround? The compiler defines for RTLVersion
and CompilerVersion
have not changed and are still 35.0
. The static compiler define is also still VER350
.
ANSWER
Answered 2022-Mar-16 at 18:57There is RTLVersion111
constant which you can use to determine whether you are dealing with 11.1
QUESTION
In a Delphi application I am using since years the following code to export xlxs to pdf:
...ANSWER
Answered 2022-Mar-10 at 06:48Root cause of error:
Excel loses print area settings in non-English version of application when file is opened using automation.
Why this is happening:
When you define print area in a sheet, Excel internally creates a named range. It has two properties defining its name:
Name
this property is always of the formWorksheetsName!Print_Area
(if the sheet's name contains some special characters it is also enclosed in single quotes).NameLocal
has similar structure, but the second part is translated into the language of the application.
This is what it looks like when you open the file in Excel and inspect these properties in VBA, but when you open the same file using automation (for example using the code in question), then NameLocal
is no longer translated. This bug causes the named range to not be recognized correctly as print area. oSheet.PageSetup.PrintArea
returns an empty string.
Workaround:
Restore original print area after opening the file using:
oSheet.PageSetup.PrintArea:='Print_Area';
This line of code will throw an exception when there was no print area defined in sheet, so there are two options:
- Place the line inside
try
..except
block. - Iterate the
Names
collection and look for aName
ending with!Print_Area
, for example:
QUESTION
So I created a class: TWorkerThread = class(TThread)
. In the TWorkerThread
Constructor I set FreeOnTerminate := True
.
I then added a private Worker
variable to my TForm
. When I instantiate TWorkerThread
for Worker
, I always use CreateSuspended := False
.
The only interactions I need to have with the thread once started is to cancel the process (Terminate
) and check if the process is over (that check is user event based).
To check if the thread is still active I do:
...ANSWER
Answered 2022-Feb-04 at 12:25What's the correct way in Delphi to check if a non-Suspended created TThread with FreeOnTerminate = True is still executing?
There is none.
As soon as self destroying thread is started, you are no longer allowed to touch reference holding such thread from outside code, because that reference can become stale at any time.
Under some circumstances (if logic handling OnTerminate
call in DoTerminate
is not modified in your custom thread class) you can safely access thread reference from OnTerminate
event handler. However, that will not help you solve your problem because you cannot wait on self destroying thread. On Windows such code causes exception that can be caught and handled, but on other platforms it causes undefined behavior and random deadlocks. But even on Windows writing such code is not advisable.
If you need to check status of a thread, cancel it or wait for it, you cannot use self destroying threads. Period. (For those that may object previous statement, yes under some circumstances some of those things are possible, but they commonly lead to shooting yourself in the foot).
You can use following workflow with TWorkerThread
, providing that you leave FreeOnTerminate
on False
in your thread constructor and construct unsuspended thread. All following methods must be called from the main thread to avoid race condition on Worker
reference. Having one extra thread that does nothing while your form is open will not cause you any trouble.
QUESTION
I have just written this easy macro in Excel VBA for merging a group of selected cells:
...ANSWER
Answered 2022-Feb-03 at 20:17DisplayAlerts
is an undeclared variable.
Certain Application
properties and methods can (effectively) have the Application
omitted:
ActiveCell
,ActiveSheet
,ActiveWorkbook
,ActiveWindow
,Addins
,Charts
,Selection
, etc.Calculate
,Evaluate
,Intersect
,Run
,Union
, etc.
(but see this answer why/how this works):
A boolean property such as DisplayAlerts
(EnableEvents
, ScreenUpdating
, etc) doesn't fall into the above category.
A golden rule in order not to fall into such a trap is the usage of Option Explicit
while writing macros.
QUESTION
In my applications there are many cases when I have several groups of TLabel
followed by a TEdit
on my Forms, you know... when some properties needs to be edited. I want to align vertically those controls so that their font baseline will be on the same line. I need to do this at runtime, after I scale the Form and everything is messed up. Do yo know if there is a way to do that ? I saw that Delphi IDE does it verry easy at design time...
Edit: I managed to get the position of the baseline relative to font margins, with GetTextMetrics
but now I don't know where the font Top is positioned in the control client area (TLabel and TEdit)...
ANSWER
Answered 2022-Jan-31 at 16:58This is the code that aligns some common controls... I don't know if it covers all the cases, but what I've tried so far has worked perfectly. It works in current Windows versions but God knows what will happen in future versions, when they will change the way controls are drawn.
QUESTION
I use Delphi 10.3 Rio, and need to know the screen PixelsPerInch ratio to scale my application accordingly.
Calculating with the formula, my screen has 142 ppi. (Real values are: 15.5" diagonal and 1920 x 1080 resolution). But when I read in Delphi the Screen.PixelsPerInch
property, I get 134 ! And this value is reportend in PixelsPerInch
property of every TForm
I create, too. So, why this difference and which is the real ppi ?
AIDA64 reports the real value of 142 ppi... So I think is something wrong with the pixels per inch ratio in Delphi...
Edit:
I managed to get the real PPI with this code... but I cannot change this in every Delphi component. So, if I use this value in my components, won't I mess everything up ?
...ANSWER
Answered 2022-Jan-21 at 08:08There is no bug and Delphi returns proper value in PixelsPerInch
.
PPI OS will return for the purpose of scaling your application is not the actual PPI value of the actual display device, but virtual pixel density.
For developing applications the PPI value you need is the one that OS gives you, not the actual PPI value of the display device.
Everything you need to know is baseline PPI for the OS and current PPI or the scale factor. Using those numbers you can then calculate number of scaled pixels from some baseline pixel value.
For instance, if your control baseline width is 100 pixels and screen scale is 150% from the baseline PPI then your runtime control size will be 150 pixels.
Different operating systems have different baseline PPI.
OS Baseline PPI Windows 96 PPI macOS 72 PPI Android 160 PPI iOS 163 PPICalculation:
QUESTION
In Delphi 10.3, I had written some Excel automation code. I used variants. When the routine was finished, I cleared and freeAndNil the Variant...
...ANSWER
Answered 2022-Jan-11 at 19:50Both of these code snippets are wrong. You don't call Free
on a variant. You call Free
on an object instance. Simply remove that line.
QUESTION
I use TOSVersion.ToString function (uses SysUtils) to detect Windows version. However this is what I get in Windows11:
Windows 10 (Version 10.0, Build 21996, 64-bit Edition)
Is there any reliable way to detect Windows 11? I'm using Delphi 10.3.3.
UPDATE: Windows 11 is officially released and I tried again. Here is what I get:
Windows 10 (Version 10.0, Build 22000, 64-bit Edition)
ANSWER
Answered 2021-Jul-25 at 10:40As Remy pointed out: using the WinAPI you risk of being in some compatibility mode, resulting in getting a version reported that is lower than the actual.
One alternative is to check the file version of expected files, i.e.
%windir%\system32\ntoskrnl.exe
or%windir%\explorer.exe
using
GetFileVersionInfo()
andVerQueryValue()
- theHiWord(dwFileVersionLS)
should be22000
or higher (according to Windows NT build/release number).Another is to look in the Registry under
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\
at the text valuesCurrentBuild
andCurrentBuildNumber
, checking if the highest of both is22000
or higher.David already wrote a detailled answer in Checking Windows version on W10 with even more alternatives, although concentrating on the high/low version numbers, not the build. But WMI might help.
(This only works in retrospective with confirmed knowledge.) Check which API exports are available: the idea is that specific functions were introduced with specific Windows releases/versions, so if importing fails for one you know you're on a version below. An outdated example and an outdated list of minimum versions per function will give you an idea. Now you "only" have to find out which new functions are introduced with Windows 11.
Those are all not bulletproof, but you could combine them and then draw conclusions. And after all that you can still try your approach to parse texts instead of relying on numbers only. It also shows how easily you can manipulate your system into reporting different versions as per which method is used.
QUESTION
I'm having some trouble using method resolution clause in Delphi 10.4.
Say I want to create a cat and a dog repository. In this case the TAnimalRepository has both cats and dogs, so I would like to implement both the cat and dog interfaces in that class.
Example:
...ANSWER
Answered 2021-Dec-21 at 14:53You need to get rid of the additional declarations of GetAll in ICatRepository and IDogRepository. If you just leave the GUID in these interfaces all works as expected.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Delphi
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page