Thursday, June 12, 2008

Changing display frequency

I recently bought an LCD monitor to connect to my notebook at work. It's a widescreen Benq with resolution 1440x900 and from the day I installed it my work turned from boring chore into a beautiful pleasure (more or less :) ).

However for some kind of strange reason every time I reconnect the notebook to the docking station, the monitor sets the refresh frequency 60Hz.

Some people say, they can't see the difference, but I'm really not one of them. I really can't stand looking at 60Hz.

Being the lazy person I am, I decided to write a program, so that I don't have to do eight clicks every time I come to work.

After about a twelve seconds of googling, I've found the function I need is ChangeDisplaySettins

Braindead easy program for changing the frequency follows:

#include <windows.h>

int main(void)
{
 DEVMODE d;
 memset(&d, 0, sizeof d);
 
 d.dmSize = sizeof d;
 d.dmDisplayFrequency = 75;
 d.dmFields = DM_DISPLAYFREQUENCY;

 ChangeDisplaySettings(&d, CDS_UPDATEREGISTRY);

 return 0;
}

For convenience purposes binary version follows frequency.zip (5kB).

Thanks to Mark James for creating the amazing Silk icons.

2 comments:

Amit Chakradeo said...

You probably know this already, but it is also way too easy to do in python (with win32 extensions). The following code achieves exactly what you mentioned...

import win32api
p=win32api.EnumDisplaySettings(None, 0)
print "Current Display frequency = ", p.DisplayFrequency
p.DisplayFrequency=75
win32api.ChangeDisplaySettings(p,0)

--Amit

ondrew said...

Thanks for the tip, Amit. Reminds me, I should use more Python :).