-
Jul 5th, 2015, 03:18 PM
#1
Thread Starter
Addicted Member
[RESOLVED] How to use setprocessdpiawarenes in VB6
Just upgraded my Windows 10 to build 10162 to find that setprocessdpiaware is no longer supported!
Does anyone know how to declare and use setprocessdpiawareNESS in VB6?
I want to use the function not a manifest entry.
-
Jul 5th, 2015, 04:28 PM
#2
Re: How to use setprocessdpiawarenes in VB6
SetProcessDPIAware has been deprecated for a decade.
About the only reason I can imagine anyone ever using it might be Windows XP support, but few Windows XP systems ever faced high DPI issues because monitor technology had not gotten out of control until XP was retired in 2006.
In any case of XP is your reason for this you could always use both and trap/ignore the exception on your attempt to call SetProcessDPIAware on uplevel systems. I can't think of any other workaround besides a version check, but that amounts to the same thing anyway because you still need both.
-
Jul 6th, 2015, 12:12 AM
#3
Thread Starter
Addicted Member
Re: How to use setprocessdpiawarenes in VB6
Thank you for answering but you misread my question which was.....
Does anyone know how to declare and use setprocessdpiawareNESS in VB6?
Last edited by JohnTurnbull; Jul 6th, 2015 at 12:47 AM.
-
Jul 6th, 2015, 02:34 AM
#4
Re: How to use setprocessdpiawarenes in VB6
Try this (untested!) code:
Code:
Option Explicit
Private Enum PROCESS_DPI_AWARENESS
Process_DPI_Unaware = 0
Process_System_DPI_Aware = 1
Process_Per_Monitor_DPI_Aware = 2
End Enum
#If False Then
Dim Process_DPI_Unaware, Process_System_DPI_Aware, Process_Per_Monitor_DPI_Aware
#End If
Private Declare Function SetProcessDpiAwareness Lib "shcore.dll" (ByVal Value As PROCESS_DPI_AWARENESS) As Long
Private Sub Main()
Const S_OK = &H0&, E_INVALIDARG = &H80070057, E_ACCESSDENIED = &H80070005
Select Case SetProcessDpiAwareness(Process_System_DPI_Aware)
Case S_OK: MsgBox "The current process is set as dpi aware.", vbInformation
Case E_INVALIDARG: MsgBox "The value passed in is not valid.", vbCritical
Case E_ACCESSDENIED: MsgBox "The DPI awareness is already set, either by calling this API " & _
"previously or through the application (.exe) manifest.", vbCritical
End Select
End Sub
See the SetProcessDpiAwareness function's documentation for more info.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jul 6th, 2015, 04:04 AM
#5
Thread Starter
Addicted Member
Re: How to use setprocessdpiawarenes in VB6
Many thanks!
I couldn't find that declaration anywhere.
-
Jul 6th, 2015, 06:19 AM
#6
Re: How to use setprocessdpiawarenes in VB6
 Originally Posted by JohnTurnbull
Thank you for answering but you misread my question...
Yes, I clearly did.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|