You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
As I can surmise, EnumDisplaySettings allows you to 'enumerate' the values of ALL *available* display settings. What I need, is to specify (discover) what values are *currently* in use - specifically the Display Frequency in Hertz in use without disturbing the display or resetting it.
A global search on EnumDisplaySettings came up with only 3 matches, this being one. The other two don't shed light on what I'm seeking. They simply show how to retrieve values via a EnumDisplaySettings index -or- SET a display via an EnumDisplaySettings index which, of course, in turn returns all the data I need - but after-the-fact, so to speak. I need to know it *without* disturbing the current display settings at all.
Am I wrong?
------------------
[This message has been edited by William Fletcher (edited April 17, 2000).]
gives the current BitsPerPixel parameter. I 'don't see any animal like '%DISPLAYFREQ' in the Win32Api.inc, though, for this function. This was another one of my (apparently failed) attempts to find the current Freq in Hz.
------------------
[This message has been edited by William Fletcher (edited April 17, 2000).]
William --
I was wrong. In my program I knew frequency, because user selected a variant from available in EnumDisplaySettings.
I am afraid that it's necessary to search in registry.
I tested Windows98-registry.
YES - I see
parameter RefreshRate in HKEY_LOCAL_MACHINE\Config\0001\Display\Settings
(all others are also here).
0001 is hardware profile (??)
But if selected "by adapter", there is no such parameter.
Under NT (Win2000) -
it looks that name of key is hardware-dependent and to take it is not such easy like in Windows98.
I found that on my PC Windows changes a parameter DefaultSettings.VRefresh in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Hardware Profiles\
0001\System\CurrentControlSet\SERVICES\NV4 (chipset)...
[This message has been edited by Semen Matusovski (edited April 18, 2000).]
end sub 'buildhivetable
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
'function by ron pierce
'
function getregistryvalue(lnghivename as long, _
strkeyname as asciiz, _
strsubkeyname as asciiz, _
strdefaultvalue as string) as string
local lngregsettings as long
local lngkeyhandle as long
local lngregstatus as long
local strregvalue as asciiz * 256
local lngregvaluelen as long
local samdesiredval as long
local lpclassstr as asciiz * 15
samdesiredval = 0
lngkeyhandle = 0
lpclassstr = "registryclass"
getregistryvalue = strdefaultvalue
lngregsettings = regcreatekeyex(lnghivename, _
strkeyname, _
0&, _
lpclassstr, _
%reg_option_non_volatile, _
%key_all_access, _
byval samdesiredval, _
lngkeyhandle, _
lngregstatus)
if lngregsettings = %error_success then
strregvalue = string$(256, " ")
lngregvaluelen = 256
if regqueryvalueex(lngkeyhandle, _
strsubkeyname, _
0&, _
%reg_sz, _
strregvalue, _
lngregvaluelen) <> %error_success then
strregvalue = strdefaultvalue
lngregvaluelen = len(strregvalue) + 1 'add one to allow for the null
if regsetvalueex(lngkeyhandle, _
strsubkeyname, _
0&, _
%reg_sz, _
strregvalue, _
lngregvaluelen) <> %error_success then
beep
end if
end if
getregistryvalue = left$(strregvalue, lngregvaluelen - 1)
if regclosekey(lngkeyhandle) <> %error_success then
beep
end if
else
gregistry_error_code = lngregsettings
beep
end if
end function
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
function pbmain () as long
local x as string
local i as long
local j as long
local lhive as long
local szkeyname as asciiz * 256
local szsubkeyname as asciiz * 256
x = mid$(environ$("windir"),4)
if x <> "winnt" then
msgbox "run this under windowsnt only",%mb_iconwarning,$pgmname
exit function
end if
call buildhivetable()
'find the name of the video device in use:
lhive = %hkey_local_machine
szkeyname = "hardware\devicemap\video"
szsubkeyname = "\device\video0"
x = getregistryvalue(lhive,szkeyname,szsubkeyname,$registryerrormessage)
if x = $registryerrormessage then
msgbox x,%mb_iconerror,"error code:" & str$(gregistry_error_code)
exit function
else
msgbox hivename(lhive) & "\" & szkeyname & "\" & $crlf & $crlf & _
szsubkeyname & $crlf & $crlf & _
x,%mb_iconinformation,"registry entry for current video device:"
end if
j = instr(-1,x,"\") 'find the last backslash
i = instr(j - 2 - len(x),x,"\") 'find the next backslash to the left
x = mid$(x,i+1,j-i-1) 'extract the video device name
x = getregistryvalue(lhive,szkeyname,szsubkeyname,$registryerrormessage)
if x = $registryerrormessage then
msgbox x,%mb_iconerror,"error code:" & str$(gregistry_error_code)
exit function
else
msgbox hivename(lhive) & "\" & szkeyname & "\" & $crlf & $crlf & _
szsubkeyname & $crlf & $crlf & _
trim$(str$(asc(x))) & " hertz",%mb_iconinformation,"video refresh rate setting:"
end if
end function 'pbmain
'-------------------------------------------------------------------------------
'-------------------------------------------------------------------------------
[/CODE]
note: registry access function "getregistryvalue" c/o ron pierce in source code" forum:
iModeNum
Indicates the type of information to retrieve. This value can be a graphics mode index or one of the following values. Value Meaning
ENUM_CURRENT_SETTINGS Retrieve the current settings for the display device.
ENUM_REGISTRY_SETTINGS Retrieve the settings for the display device that are currently stored in the registry.
Graphics mode indexes start at zero. To obtain information for all of a display device's graphics modes, make a series of calls to EnumDisplaySettings, as follows: Set iModeNum to zero for the first call, and increment iModeNum by one for each subsequent call. Continue calling the function until the return value is zero.
ENUM_CURRENT_SETTINGS
I can't find a value. But this code works on my PC (Win2000)
Code:
#Compile Exe
#Register None
#Include "win32api.INC"
%ENUM_CURRENT_SETTINGS = &HFFFFFFFF ' Not sure, but works on my PC
Declare Function EnumDisplaySettings Lib "user32.dll" _
Alias "EnumDisplaySettingsA" (lpszDeviceName As Asciiz, _
iModeNum As Dword, lpDevMode As DEVMODE) As Long
Function PbMain () As Long
Dim lpDevMode As DEVMODE
EnumDisplaySettings ByVal 0, ByVal %ENUM_CURRENT_SETTINGS, lpDevMode
MsgBox Str$(lpDevMode.dmPelsWidth) + " X" + _
Str$(lpDevMode.dmBitsPerPel) + " X" + _
Str$(lpDevMode.dmPelsHeight) + " " + _
Str$(lpDevMode.dmDisplayFrequency) + " Hz"
End Function
[This message has been edited by Semen Matusovski (edited April 18, 2000).]
William --
I am also like this code , but I found for it another purpose - easy way to retrieve no. of colors.
Because it's necessary always to think about colors in 256-colors video-regime and to work with palettes every time is not comfortable, I decided to construct a function, which returns "true" or "adapted" color (to avoid classic Windows behaviour).
Code:
Declare Function EnumDisplaySettings Lib "user32.dll" _
Alias "EnumDisplaySettingsA" (lpszDeviceName As Asciiz, _
iModeNum As Dword, lpDevMode As DEVMODE) As Long
Function SelectColor (TrueColor As Long, AdaptedColor As Long) As Long
Static lpDevMode As DEVMODE
If lpDevMode.dmBitsPerPel = 0 Then _
EnumDisplaySettings ByVal 0, ByVal -1, lpDevMode
If lpDevMode.dmBitsPerPel >= 16 Then _
Function = TrueColor Else Function = AdaptedColor
End Function
Sample of usage:
hBrush = CreateSolidBrush(SelectColor(Rgb(255, 192, 128), %YELLOW))
2) Negotive.
a) Windows 95 looks 100% stupid.
b) Windows 98 doesn't understand EnumDisplaySettings with -1 (current), but it looks that understands -2 (registry settings)
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment