Set desktop metrics

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

dtw=GetSystemMetrics_(#SM_CXSCREEN)
dth=GetSystemMetrics_(#SM_CYSCREEN)
I got that right off the FAQ sticky at the top of this forum. Perhaps it could use an update?
Last edited by netmaestro on Tue Feb 21, 2006 7:58 pm, edited 2 times in total.
BERESHEIT
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> I got that right off the FAQ sticky for this forum. Perhaps it could use an update?

Now deleted from the FAQ. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

I can't seem to get it to change the frequency?
Droopy wrote:Code from DarkDragon & Gillou

Code: Select all

#DISP_CHANGE_SUCCESSFUL = 0   ; The settings change was successful.
#DISP_CHANGE_RESTART = 1      ; The computer must be restarted in order for the graphics mode to work.
#DISP_CHANGE_BADFLAGS = -4    ; An invalid set of flags was passed in.
#DISP_CHANGE_FAILED = -1      ; The display driver failed the specified graphics mode.
#DISP_CHANGE_BADMODE = -2     ; The graphics mode is not supported.
#DISP_CHANGE_NOTUPDATED = -3  ; Windows NT only: Unable to write settings to the registry.

ProcedureDLL ChangeDisplaySettings(width,height,Depth,Freq,Permanent)
  dmScreenSettings.DEVMODE 
  dmScreenSettings\dmSize = SizeOf(dmScreenSettings) 
  dmScreenSettings\dmPelsWidth = width
  dmScreenSettings\dmPelsHeight = height
  dmScreenSettings\dmBitsPerPel = Depth
  dmScreenSettings\dmDisplayFrequency=Freq
  dmScreenSettings\dmFields = 262144 | 524288 | 1048576 
  
  If Permanent
    retour=ChangeDisplaySettings_(@dmScreenSettings, 1) 
  Else
    retour=ChangeDisplaySettings_(@dmScreenSettings, 4) 
  EndIf
  
  ProcedureReturn retour
EndProcedure

;/ Test
ChangeDisplaySettings(1024,768,16,70,0)
MessageRequester("Change Display Settings","OK to Restore")
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Change the line:

Code: Select all

dmScreenSettings\dmFields = 262144 | 524288 | 1048576 
to:

Code: Select all

dmScreenSettings\dmFields = 262144 | 524288 | 1048576 | 4194304
to include the displayfrequency in the selected fields. Right now all you've got in there is width, height and depth. If you don't specify a field, it won't be modified.
BERESHEIT
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

netmaestro wrote:Change the line:

Code: Select all

dmScreenSettings\dmFields = 262144 | 524288 | 1048576 
to:

Code: Select all

dmScreenSettings\dmFields = 262144 | 524288 | 1048576 | 4194304
to include the displayfrequency in the selected fields. Right now all you've got in there is width, height and depth. If you don't specify a field, it won't be modified.
DOH! :oops:

Thanks! :wink:
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

It's possible the code you're using was written for a version of PureBasic that didn't have these devmode constants defined. PureBasic 4.0 has them, so it really would be more readable (and easier to notice something missing!) if you write it this way:

Code: Select all

dmScreenSettings\dmFields = #DM_PELSWIDTH | #DM_PELSHEIGHT | #DM_BITSPERPEL | #DM_DISPLAYFREQUENCY
BERESHEIT
TheCorporation
User
User
Posts: 11
Joined: Fri Sep 15, 2006 8:04 am
Location: FR

Post by TheCorporation »

Is it possible to let the change made to resolution when quitting Pure Basic ?

(Because this source code (or PB ?) get back to default settings when ending).
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

TheCorporation wrote:Is it possible to let the change made to resolution when quitting Pure Basic ?

(Because this source code (or PB ?) get back to default settings when ending).
Yes by changing the second value of "ChangeDisplaySettings". Just look it up in windows api to get the correct value.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
Post Reply