How to Determine the Screen Resolution

Posted December 15th @ 9:14 pm by m3Rlin

There are two ways to determine the screen’s height and width.
1) Use the global Screen variable.

uses
Forms;

Screen.Height { Screen height in pixels }
Screen.Width { Screen width in pixels }

2) Use the Windows API GetSystemMetrics() function. This function can be useful in applications that don’t use the VCL like [...]

How to Get a String’s Width in Pixels, Not in Characters

Posted December 15th @ 7:27 am by m3Rlin

To determine the width of a string in pixels using the active font and output it’s best to use this method:

(* sString - (string) Can be any string constant or variable.
**
** For example:
** TCanvas.TextWidth(’m3Rlin’);
** TCanvas.TextWidth(Edit1.Text);
** TCanvas.TextWidth(OpenDialog1.FileName);
[...]