Results 1 to 6 of 6

Thread: [RESOLVED] How to use setprocessdpiawarenes in VB6

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    159

    Resolved [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.

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,480

    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.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    159

    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.

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    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)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    159

    Re: How to use setprocessdpiawarenes in VB6

    Many thanks!
    I couldn't find that declaration anywhere.

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,480

    Re: How to use setprocessdpiawarenes in VB6

    Quote Originally Posted by JohnTurnbull View Post
    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
  •  



Click Here to Expand Forum to Full Width