Blog Options
Archive
<< April 2024 >>-
Wednesday 24
- Expanding the StellarDS.io tooling -
Monday 22
- Easy Guide to Building a Pexels Gallery App with TMS WEB Core -
Wednesday 17
- New free component for sophisticated file uploads with TMS WEB Core -
Tuesday 16
- Closing the gap with TMS FNC UI Pack new additions -
Thursday 11
- Unveiling the Latest Enhancements in TMS VCL UI Pack -
Friday 5
- TMS components and Delphi and C++Builder 12.1 -
Wednesday 3
- Customizing the login page of your application using TMS Sphinx
- A Python library for using StellarDS.io effortlessly
- Introducing: How it Works with Holger - Building a Pexels gallery app with TMS WEB Core video series
- TMS FNC Cloud Pack with StellarDS.io backend: unparalleled productivity in VCL & FMX
Authors
- Bernard Roussely (1)
- Wagner Landgraf (82)
- Roman Yankovsky (2)
- Bart Holvoet (27)
- Aaron Decramer (18)
- Pieter Scheldeman (99)
- Nancy Lescouhier (32)
- Adrian Gallero (33)
- Bruno Fierens (404)
- Marcos Douglas B. Santos (5)
- Wagner R. Landgraf (1)
- Bradley Velghe (16)
- Bernard (2)
- Andrew Simard (86)
- Holger Flick (15)
- Gjalt Vanhouwaert (30)
- Tunde Keller (22)
- Masiha Zemarai (119)
Blog
All Blog Posts | Next Post | Previous PostFNC Code Gems: Display information and common folders
Bookmarks:Tuesday, July 16, 2019
The FNC framework helps you to develop framework-independent, cross-platform applications. It has been conceived by tmssoftware.com a couple of years ago and has recently added the web as one of its platforms fascilitating TMS Web Core.
FNC really helps you to use the same source code for Windows, MacOS, iOS, Android, Linux and Raspberry Pi. Further, you can use the same components in the frameworks that give you access to these platforms: VCL, FMX and LCL.
A lot of functionality is exposed using non-visual components as well. However, I recently found a true gem of a class in its TMSFNCUtils.pas unit. The unit, of course, is available as VCL.TMSFNCUtils.pas, FMX.TMSFNCUtils.pas, and LCL.TMSFNCUtils.pas which means it can be used in any framework.
The unit contains one significant class called TTMSFNCUtils that offers a plethora of functionality that is usually tedious to implement and repetitive.
Today, we will focus on two different aspects in this blog post, and I will post more functionality in the coming weeks.
Display attributes
As blogged a couple of days ago, getting information about your display is very important so that you can scale your images correctly.TTMSFNCUtils gives you two very useful methods to get the relevant information about your forms and components quickly. Knowing what DPI your display uses is only half the work as you also need to know what DPI a certain component was designed for:
type TTMSFNCUtils = class public class function IsHighDPIScale: Boolean; class function GetDPIScale({%H-}AOwner: TComponent = nil): Single; end;
Be aware, that all methods are class-methods, i.e. you can determine if the current form uses a High DPI scale using:
LIsHighDPI := TTMSFNCUtils.IsHighDPIScale;
GetDPIScale allows you to specify a component or a form. If you specify nil the DPI scale of the form will be returned.
Getting common folders
Any application I have built so far needed to know the users documents directory and the application directory. The utility class provides cross-platform helper methods for both:
type TTMSFNCUtils = class public class function GetDocumentsPath: String; class function GetAppPath: String; end;
Getting the users document directory and the application directory now becomes two lines of code for all supported platforms:
LMyDocPath := TTMSFNCUtils.GetDocumentsPath; LAppPath := TTMSFNCUtils.GetAppPath;
Providing flexible classes as TTMSFNCUtils, the framework truly takes away the chores of multi-framework-multi-platform development.
Holger Flick
Bookmarks:
This blog post has not received any comments yet.
All Blog Posts | Next Post | Previous Post