Author Topic: Detect desktop resolution  (Read 957 times)

JGFarris

  • Newbie
  • *
  • Posts: 49
    • My Facebook Page
Detect desktop resolution
« on: January 09, 2022, 02:29:12 PM »
How can I get VA to detect the current desktop resolution?
Jerry Farris, Jr.
Entrepreneur, Programmer and Disability Advocate
jerry@jerryfarris.com

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Detect desktop resolution
« Reply #1 on: January 09, 2022, 02:54:32 PM »
Hi, Jerry.  You're going to want to use an inline function for that, as you would need to be specific about what display you're trying to address.  'Primary screen', all screens, screen X, the screen VA is currently located on, etc.  (gets a little bit hairy).

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Detect desktop resolution
« Reply #2 on: January 09, 2022, 02:55:37 PM »
Assuming you want the size of the primary display, that can be done using an inline function like
Code: [Select]
using System.Drawing;
using System.Windows.Forms;

public class VAInline
{
public void main()
{
Rectangle screenArea = Screen.PrimaryScreen.Bounds;

VA.SetInt("screenWidth", screenArea.Width);
VA.SetInt("screenHeight", screenArea.Height);
}
}
which should set the "screenWidth" and "screenHeight" variables to the relevant values.

JGFarris

  • Newbie
  • *
  • Posts: 49
    • My Facebook Page
Re: Detect desktop resolution
« Reply #3 on: January 09, 2022, 06:15:11 PM »
Thanks, I will give that a try.
Jerry Farris, Jr.
Entrepreneur, Programmer and Disability Advocate
jerry@jerryfarris.com