Categories

CODE
Visual C++ Programming
C++ (Non Visual C++ Issues)
Modern Windows Apps (Metro)
C++ and WinAPI
Managed C++ and C++/CLI
Visual C++ Bugs & Fixes
Graphics Programming
Multithreading
Network Programming
Driver Development
Visual Basic 6.0 Programming
Visual Basic .NET
Crystal Reports
C-Sharp Programming
Managed C++
Visual Basic .NET
ASP.NET
.NET Framework
ADO.NET
Windows Presentation Foundation (WPF) & XAML forum
Silverlight
.NET Installation and Configuration Issues
Java Programming
AJAX
Scripting - Client Side
Database
XML
Wireless/Mobile Development
Assembly
Scripting - Server Side (PHP, Perl, etc.)
Python
General Developer Topics
Project Planning, Design, and Management
Testers and Testing
Algorithms & Data Structures
General Discussion / Chit Chat
Announcements, Press Releases, & News
Feedback
Articles Suggestions
Testing Area
Programming Projects
C# Game(s) Project
Game Engine Project
C++ Coding Project
Project: Code War
Slow Chat: Talk with Microsoft Developer Teams
Slow Chat: Developing Multithreaded Applications
Slow Chat: C++0x
Slow Chat: Visual C++: Yesterday, Today, and Tomorrow
Directory Services
General Windows and DNA Programming
Windows OS Issues
Open Positions (Jobs)
Looking for Work
Visual Basic .NET FAQs
Visual Basic FAQs
CodeGuru Individual FAQs
CodeGuru Individual Visual Basic FAQs

Resources

Java Database
Linux
Coding
Mobile
Hardware
Software Development
Software Development
iOS,OS X
iOS,OS X
ORACLE
IBM DEVELOPER
IBM DEVELOPER
MSDN
MSDN


Tags

Visual C++ Programming

Ask questions about Windows programming with Visual C++ and help others by answering their questions.

problem setting monitor frequency


I made a simple MFC app that uses a slider control to allow the user to adjust their monitor refresh frequency. i dont really have a reason for this other than i just thought itd be a neat little trick to add to my bag of tricksy programs. the problem is it doesnt seem to work.    m_Frequency is a slider control object      here is the code inside OnInitDialog()      	Code:  	m_Frequency.SetRange(1,90,TRUE);    DISPLAY_DEVICE DisplayDevice;  ZeroMemory(&DisplayDevice,sizeof(DISPLAY_DEVICE));    DisplayDevice.cb=sizeof(DISPLAY_DEVICE);    EnumDisplayDevices(0,0,&DisplayDevice,0);    DEVMODE DevMode;  ZeroMemory(&DevMode,sizeof(DEVMODE));    EnumDisplaySettings(DisplayDevice.DeviceName,ENUM_CURRENT_SETTINGS,&DevMode);    CHAR lpszTemp[32];    sprintf(lpszTemp,"%d Hz",DevMode.dmDisplayFrequency);    SetDlgItemText(IDC_STATIC_FREQUENCY,lpszTemp);    if (DevMode.dmDisplayFrequency>90)  {  	m_Frequency.SetRange(0,DevMode.dmDisplayFrequency,TRUE);  }    m_Frequency.SetPos(DevMode.dmDisplayFrequency);   as you can see all that does is set the sliders range from 1 to 90 and then enums the display devices to get the name of the primary device (device 0 which im assuming should be the monitor, i dont intend for this to work on computers with multiple display devices) then it finds the current refresh rate and sets the slider position to the refresh rate (if the refresh rate is above 90 it resets the range and makes it so the max is the current refresh rate, i did this to make sure you couldnt over do it and screw the monitor up)    here is the code for the released capture thingy for the slider control. that was the only event i could find that seemed to be related to moving the slider (and it does work)      	Code:  	void CMonitorFrequencyDlg::OnReleasedcaptureSliderFrequency(NMHDR* pNMHDR, LRESULT* pResult)   {  	// TODO: Add your control notification handler code here    	DEVMODE DevMode;  	ZeroMemory(&DevMode,sizeof(DEVMODE));  	DevMode.dmDisplayFrequency=m_Frequency.GetPos();  	DevMode.dmFields=DM_DISPLAYFREQUENCY;  	DevMode.dmSize=sizeof(DEVMODE);    	ChangeDisplaySettings(&DevMode,0);    	DISPLAY_DEVICE DisplayDevice;  	ZeroMemory(&DisplayDevice,sizeof(DISPLAY_DEVICE));    	DisplayDevice.cb=sizeof(DISPLAY_DEVICE);    	EnumDisplayDevices(0,0,&DisplayDevice,0);    	ZeroMemory(&DevMode,sizeof(DEVMODE));    	EnumDisplaySettings(DisplayDevice.DeviceName,ENUM_CURRENT_SETTINGS,&DevMode);    	CHAR lpszTemp[32];    	sprintf(lpszTemp,"%d Hz",m_Frequency.GetPos());    	SetDlgItemText(IDC_STATIC_FREQUENCY,lpszTemp);  	  	*pResult = 0;  }   all that does is set the monitor refresh rate to the slider position and then it uses the code from the init dialog function to get the refresh rate then displays it (i did this to make sure it was actually changing the refresh rate rather than just reporting the slider position).    it does display the correct refresh rate when it starts but when i change it it doesnt seem to make a difference, i set to down to 1 hz and it was the same as it was at 60 hz. i also tried settinf it down to something like 45 hz closing the program and starting it up again. when i do it says 60hz.... grrr.... if it makes a difference im using windows xp pro.  				  			

  				  					I didn't think it was possible to set a display device to under 60Hz.  				  			

  				  					While it is possible to set the monitor refresh rate below 60Hz, you should be aware that setting the refresh rate to something that the monitor was not designed for can actually damage it (too low, too high, or something in-between).    For this reason, you will typically find that either Windows (or more precisely the video driver) will intervene, preventing damage to the monitor, or the monitor itself will go blank to protect itself. I suspect this is what is causing your refresh rate to stay at 60Hz (you should be thankful).    If the monitor is not smart enough to protect itself, and/or the video driver doesn't know or care (or may be set to the wrong monitor type), then it is certainly possible damage or destroy the monitor.    If I were you, I'd stick to the refresh rates permitted in your display properties dialog.    Knowing what is a good combination is something that is internally defined within the monitor device driver (and can be quite complex to get right).    Hope this helps,    - Nigel


Related Links

converting 8 bits into 11 bits
parse website data
Problem on Vista...???
the way which Windows Vista show modal dialog?
Problem in assigning value to a string variable
show IPLimage in MFC window
Replaced view not get focused in Splitter Window.
Irregular Debugging Route
base64
Reading unicode file giving wrong chars
"new" operator inside function issue
How to draw black colored outline for white colored font?
Linear Search Question
Jumping from one function to another function
[RESOLVED] File data on EditBox
visual c++ .NET 2005 ODBC driver not working