From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Screen refresh rate?

Is there a .net command or other way to detect a screens refresh rate?

 

Thanks

Graham

0 Kudos
Message 1 of 4
(2,762 Views)

A quick search reveals there is a user32.dll function (EnumDisplaySettings) that will return this information but don't ask me how to set it up. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 4
(2,726 Views)

This post is rather old, but it is always the first forum post I see when searching for calls to EnumDisplaySettings. The only code submissions I've seen have been VB dlls.

Attached is a labview example of a call to EnumDisplaySettingsA. It was meant to replicate functionality of an old 32-bit only library called "lvwinutil.lib"; I created the library in LabView after I migrated to 64-bit.

 

Please be aware that the MSDN documentation is a bit misleading, as in C programs, parts of the structure are joined as a union and are technically stored under the same offset! Always refer to VB examples where the structure is defined as "sequential" to determine the order in which clustered items should appear. To make this call in Labview, DMPositionX and DMPositionY should appear at the end of the cluster. There are also some excessive items listed on the MSDN page, for some unknown reason.

 

TO USE:

Open WinUtils->lvwinutil.lib->WinDisplay->WIN_GetDisplayMode.vi

 

Use device name: \\.\DISPLAY1

and iModenum: -1

 

If you only have one monitor to preview, \\.\DISPLAY1 will give you the results you need. For extended monitors, you'll have to increase the numeric value ex: \\.\DISPLAY2.

Be aware however that if your primary monitor is a laptop that is closed at the time of the call, the laptop is still considered the #1 enumeration, but calling it will return an error.

 

iModeNum value of -1 returns the active settings and caches settings to memory. Incrementing iModeNum will allow you to enumerate all possible settings for the display device.

 

I had to use 32-byte length clusters because you can't send an an initialized array in a cluster through to a library call; the library will treat it as an empty array and your offset will be wrong. 

Using Labview 2022, Windows 10
0 Kudos
Message 3 of 4
(884 Views)

@grahamwebb wrote:

Is there a .net command or other way to detect a screens refresh rate?

 

Thanks

Graham


Does this mean:

a) detect refresh rates (get an event if a refresh rate happens) or

b) read the refresh rate (get the refresh rate value, e.g. 60 Hz).

 

a) could probably be done with DirectX. (DirectX WaitForVerticalBlank, which will poll the status). I do have a faint recollection of trying stuff like this, but that must have been at least 15 years ago.

 

Note there's a vertical and horizontal refresh rate. Age ago these where both used to do funky graphical stuff in assembly.

 

Searching for Vertical black or vertical refresh rate will give better results, although nobody seems to care for this anymore. It's all being dealt with at a driver\library level.

0 Kudos
Message 4 of 4
(840 Views)