How to compare double in delphi?

The Math.pas unit includes functions such as SameValue(), IsZero(), CompareValue() which handle floating type comparisons and equality. const EPSILON = 0.0000001; begin if CompareValue(p, pMax, EPSILON) = GreaterThanValue then ShowMessage(‘p greater than pMax’); The constant GreaterThanValue is defined in Types.pas If you’re comparing very large values you shouldn’t use a constant for epsilon, instead your … Read more

Windows Visual Themes: Gallery of Parts and States?

I have created a small Windows application, programmed with the table at Parts and States. This application lets the programmer browse and explore all parts and states, using the current OS theme. (High-Res) It can be downloaded at https://privat.rejbrand.se/UxExplore.exe The (Delphi, Win32 API) source, which is too long to be posted here (due to hundreds … Read more

How can I tell if another instance of my program is already running?

As Jon first suggested, you can try creating a mutex. Call CreateMutex. If you get a non-null handle back, then call GetLastError. It will tell you whether you were the one who created the mutex or whether the mutex was already open before (Error_Already_Exists). Note that it is not necessary to acquire ownership of the … Read more

How to use the TTaskDialog?

If you can’t find the documentation, then write it: The Hello World of a Task Dialog with TTaskDialog.Create(Self) do try Caption := ‘My Application’; Title := ‘Hello World!’; Text := ‘I am a TTaskDialog, that is, a wrapper for the Task Dialog introduced ‘ + ‘in the Microsoft Windows Vista operating system. Am I not … Read more

How can I mark a property as deprecated in delphi?

No, this is not possible. According to the documentation, The ‘hint’ directives platform, deprecated, and library may be appended to any declaration. These directives will produce warnings at compile time. Hint directives can be applied to type declarations, variable declarations, class, interface, and structure declarations, field declarations within classes or records, procedure, function, and method … Read more

Can a Windows dll retrieve its own filename?

I think you’re looking for GetModuleFileName. http://www.swissdelphicenter.ch/torry/showcode.php?id=143: { If you are working on a DLL and are interested in the filename of the DLL rather than the filename of the application, then you can use this function: } function GetModuleName: string; var szFileName: array[0..MAX_PATH] of Char; begin FillChar(szFileName, SizeOf(szFileName), #0); GetModuleFileName(hInstance, szFileName, MAX_PATH); Result := … Read more

Assigned vs nil

TL;DR The official documentation states Assigned(P) corresponds to the test P <> nil for a pointer variable, and @P <> nil for a procedural variable. Hence, for a non-procedural pointer variable (such as a variable of type PInteger, PMyRec, TBitmap, TList<integer>, or TFormClass), Assigned(P) is the same thing as P <> nil. However, for a … Read more

Delphi: How to organize source code to increase compiler performance?

Some things that could slow down the compiler Redundant units in your uses clause. See this question for a link to CnPack. Not explicitly adding units to your project file. You’ve already seem to have covered that. Changed compiler settings, most notably include TDD32 info. Try to get rid of unused units in your uses … Read more

Interfaces and properties

No. Interfaces are implemented as function tables (basically a simple virtual method table) and the compiler needs to know there’s a function to map the property onto. You can declare a property on an interface, but it has to have functions as getter/setter values, not fields. You can make it read-only or write-only, though.