Jump to content

Recommended Posts

Posted

I would download a graphix library... then do a dll call to the dll they provide... usually they will only give u a c++ or c++ like language example.. so its gonna be kinda hard... but yeah, just download a small graphics library, and do a dll call to the dll they provide...

Posted (edited)

this is an updated version from Larry to work with latest beta, might need some more work

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
    Local $width, $height, $bpp, $freq
    
;~ $a = DisplayEnumRes(0, $width, $height, $bpp, $freq)
;~ MsgBox(4096,$a,$width & @LF & $height & @LF & $bpp & @LF & $freq)
    
;~ $a = DisplayEnumRes(1, $width, $height, $bpp, $freq)
;~ MsgBox(4096,$a,$width & @LF & $height & @LF & $bpp & @LF & $freq)
    
    MsgBox(4096, "", DisplayChangeRes(1024, 768, 32, 60))
    
    MsgBox(4096, "", DisplayChangeRes(1024, 768, 32, 75))
EndFunc  ;==>_Main

Func DisplayEnumRes($index, ByRef $width, ByRef $height, ByRef $bpp, ByRef $freq)
    Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]")
    
    Local $b = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", $index, "ptr", DllStructGetPtr($DEVMODE))
    
    If @error Then
        $b = 0
    Else
        $b = $b[0]
    EndIf
    
    If $b <> 0 Then
        $width = DllStructGetData($DEVMODE, 4, 2)
        $height = DllStructGetData($DEVMODE, 4, 3)
        $bpp = DllStructGetData($DEVMODE, 4, 1)
        $freq = DllStructGetData($DEVMODE, 4, 5)
    EndIf
    
    $DEVMODE = 0
    
    Return $b
EndFunc  ;==>DisplayEnumRes

Func DisplayChangeRes($width, $height, $bpp, $freq)
    Local Const $DM_PELSWIDTH = 0x00080000
    Local Const $DM_PELSHEIGHT = 0x00100000
    Local Const $DM_BITSPERPEL = 0x00040000
    Local Const $DM_DISPLAYFREQUENCY = 0x00400000
    Local Const $CDS_TEST = 0x00000002
    Local Const $CDS_UPDATEREGISTRY = 0x00000001
    Local Const $DISP_CHANGE_RESTART = 1
    Local Const $DISP_CHANGE_SUCCESSFUL = 0
    Local Const $HWND_BROADCAST = 0xffff
    Local Const $WM_DISPLAYCHANGE = 0x007E
    
    Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]")
    
    Local $b = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE))
    If @error Then
        $b = 0
    Else
        $b = $b[0]
    EndIf
    If $b <> 0 Then
        DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5)
        DllStructSetData($DEVMODE, 4, $width, 2)
        DllStructSetData($DEVMODE, 4, $height, 3)
        DllStructSetData($DEVMODE, 4, $bpp, 1)
        DllStructSetData($DEVMODE, 4, $freq, 5)
        
        $b = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST)
        
        If @error Then
            $b = -1
        Else
            $b = $b[0]
        EndIf
        
        Select
            Case $b = $DISP_CHANGE_RESTART
                $DEVMODE = 0
                Return 2
            Case $b = $DISP_CHANGE_SUCCESSFUL
                DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY)
                DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _
                        "int", $bpp, "int", $height * 2 ^ 16 + $width)
                $DEVMODE = 0
                Return 1
            Case Else
                $DEVMODE = 0
                Return $b
        EndSelect
    EndIf
EndFunc  ;==>DisplayChangeRes

#cs
    Func DisplayChangeDPI($dpi)
    {
    DEVMODE DevM;
    long ret;
    
    EnumDisplaySettings(NULL,0,&DevM);
    
    DevM.dmFields = DM_LOGPIXELS;
    DevM.dmLogPixels = dpi;
    
    ret = ChangeDisplaySettings(&DevM, CDS_TEST);
    
    switch(ret)
    {
    case DISP_CHANGE_RESTART:
    return 2;
    case DISP_CHANGE_SUCCESSFUL:
    ChangeDisplaySettings(&DevM, CDS_UPDATEREGISTRY);
    SendMessage(HWND_BROADCAST, WM_DISPLAYCHANGE, (WPARAM)DevM.dmBitsPerPel, (LPARAM)(DevM.dmPelsHeight * 2 ^ 16 + DevM.dmPelsWidth));
    return 1;
    default:
    return 0;
    }
    }
#ce
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

  • 7 months later...
Posted

Is there a way to change the DPI for only one running program? like if i have a game i want to run at 90 dpi, while my desktop is running at 120 dpi, how would i do that?

Posted (edited)

You could use a script to start the game. Have it first change the refresh rate, then start the game. When you close the game, have it change it back, then exit the script. Maybe something like this:

Opt("MustDeclareVars", 1)
dim $width, $height, $bpp, $freq
DisplayChangeRes($width, $height, $bpp, $freq) ;changes to refresh for game
runwait("The name of game", "Path")
DisplayChangeRes($width, $height, $bpp, $freq) ;changes to refresh for normal use
exit

Func DisplayEnumRes($index, ByRef $width, ByRef $height, ByRef $bpp, ByRef $freq)
    Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]")
    
    Local $b = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", $index, "ptr", DllStructGetPtr($DEVMODE))
    
    If @error Then
        $b = 0
    Else
        $b = $b[0]
    EndIf
    
    If $b <> 0 Then
        $width = DllStructGetData($DEVMODE, 4, 2)
        $height = DllStructGetData($DEVMODE, 4, 3)
        $bpp = DllStructGetData($DEVMODE, 4, 1)
        $freq = DllStructGetData($DEVMODE, 4, 5)
    EndIf
    
    $DEVMODE = 0
    
    Return $b
EndFunc  ;==>DisplayEnumRes

Func DisplayChangeRes($width, $height, $bpp, $freq)
    Local Const $DM_PELSWIDTH = 0x00080000
    Local Const $DM_PELSHEIGHT = 0x00100000
    Local Const $DM_BITSPERPEL = 0x00040000
    Local Const $DM_DISPLAYFREQUENCY = 0x00400000
    Local Const $CDS_TEST = 0x00000002
    Local Const $CDS_UPDATEREGISTRY = 0x00000001
    Local Const $DISP_CHANGE_RESTART = 1
    Local Const $DISP_CHANGE_SUCCESSFUL = 0
    Local Const $HWND_BROADCAST = 0xffff
    Local Const $WM_DISPLAYCHANGE = 0x007E
    
    Local $DEVMODE = DllStructCreate("byte[32];int[10];byte[32];int[6]")
    
    Local $b = DllCall("user32.dll", "int", "EnumDisplaySettings", "ptr", 0, "long", 0, "ptr", DllStructGetPtr($DEVMODE))
    If @error Then
        $b = 0
    Else
        $b = $b[0]
    EndIf
    If $b <> 0 Then
        DllStructSetData($DEVMODE, 2, BitOR($DM_PELSWIDTH, $DM_PELSHEIGHT, $DM_BITSPERPEL, $DM_DISPLAYFREQUENCY), 5)
        DllStructSetData($DEVMODE, 4, $width, 2)
        DllStructSetData($DEVMODE, 4, $height, 3)
        DllStructSetData($DEVMODE, 4, $bpp, 1)
        DllStructSetData($DEVMODE, 4, $freq, 5)
        
        $b = DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_TEST)
        
        If @error Then
            $b = -1
        Else
            $b = $b[0]
        EndIf
        
        Select
            Case $b = $DISP_CHANGE_RESTART
                $DEVMODE = 0
                Return 2
            Case $b = $DISP_CHANGE_SUCCESSFUL
                DllCall("user32.dll", "int", "ChangeDisplaySettings", "ptr", DllStructGetPtr($DEVMODE), "int", $CDS_UPDATEREGISTRY)
                DllCall("user32.dll", "int", "SendMessage", "hwnd", $HWND_BROADCAST, "int", $WM_DISPLAYCHANGE, _
                        "int", $bpp, "int", $height * 2 ^ 16 + $width)
                $DEVMODE = 0
                Return 1
            Case Else
                $DEVMODE = 0
                Return $b
        EndSelect
    EndIf
EndFunc  ;==>DisplayChangeRes

I didn't test this. You may need to tweak it.

Edited by vollyman

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...