DigDeep Posted July 11, 2017 Share Posted July 11, 2017 @phillip123adams I was using your GetDPI.au3 but it is giving error: Can not initiaze a variable with itself at line 8, Line 8 = Local $hDC = DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) Could you please suggest. Also, I wanted to have the DPI as 120 instead of 96. Link to comment Share on other sites More sharing options...
benners Posted July 13, 2017 Share Posted July 13, 2017 The error is because the variable $hDC has already been declared and is used as one of the parameters in the dllcall. The return value from the call is not used in the function so you can remove the Local $hDC part. It maybe OK to just comment out the line. as I don't think it is needed in this instance. Link to comment Share on other sites More sharing options...
Trong Posted July 13, 2017 Share Posted July 13, 2017 Comment or Remove Local $hDC or rename to anythink ! MsgBox(64, "", "DPI= " & _GetDPI() & @CRLF & " DPIRat= " & @extended) Func _GetDPI() Local $iDPI, $iDPIRat, $Logpixelsy = 90, $hWnd = 0 Local $hDC = DllCall("user32.dll", "long", "GetDC", "long", $hWnd) Local $aRet = DllCall("gdi32.dll", "long", "GetDeviceCaps", "long", $hDC[0], "long", $Logpixelsy) DllCall("user32.dll", "long", "ReleaseDC", "long", $hWnd, "long", $hDC) $iDPI = $aRet[0] ;; Set a ratio for the GUI dimensions based upon the current DPI value. If $iDPI < 145 And $iDPI > 121 Then $iDPIRat = $iDPI / 95 ElseIf $iDPI < 121 And $iDPI > 84 Then $iDPIRat = $iDPI / 96 ElseIf $iDPI < 84 And $iDPI > 0 Then $iDPIRat = $iDPI / 105 ElseIf $iDPI = 0 Then $iDPI = 96 $iDPIRat = 94 Else $iDPIRat = $iDPI / 94 EndIf Return SetError(0, $iDPIRat, $iDPI) EndFunc ;==>_GetDPI Regards, Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now