none
Hi Resolution Screen Development on laptop shrinks the form.

    Question

  • Windows 7 Desktop screen is 1280 * 800 with 125% works great

    All of my programs were developed on this machine.

    I am using Visual Studio 2017 Professional Visual Basic.

    Windows 10 Laptop screen is 3840 * 2160 with 250%. Text boxes overlap and screen is much smaller. Laptop is Lenovo Yoga.

    My question: How should I approach this problem to fix for the development side?


    Charlie Soroka

    Friday, February 09, 2018 9:00 PM

Answers

  • Hi Tommy: Thanks for your reply, I found one solution, see reply to Karen. Thank you for your link.

    Charlie Soroka

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 2:24 AM
  • Hi Karen: Thanks for help on registry code. Copy of Code that will build key if it does not exist
    and turn dpiaware on or off.

    Imports Microsoft.Win32

    Public Class Form1
        Dim reg_key As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\devenv.exe"
        Dim regKey As RegistryKey
        Dim DB_aware As String = "Change Status to DB-AWARE"
        Dim DB_Notaware As String = "Change Status to DB-NotAWARE"
        Dim readValue As Integer
        Private Sub BTN_ChangeStatus_Click(sender As Object, e As EventArgs) Handles BTN_ChangeStatus.Click
            Try
                If My.Computer.Registry.GetValue(reg_key, "dpiawareness", Nothing) Is Nothing Then 'Check if Key Exist
                    MsgBox(reg_key & " Key Not Found, Press any key")
                    Close()
                Else ' Key exist now get value
                    readValue = My.Computer.Registry.GetValue(reg_key, "dpiawareness", Nothing)
                    If readValue = 0 Then
                        My.Computer.Registry.SetValue(reg_key, "dpiawareness", 1)
                    ElseIf readValue = 1 Then
                        RB_Aware.Checked = True
                        My.Computer.Registry.SetValue(reg_key, "dpiawareness", 0)
                    Else
                        MsgBox("Error, Value returned was not a 0 or 1, Press any key")
                    End If
                End If
            Catch ex As Exception
                MsgBox("error")
            End Try
            Call DPI_Status()
        End Sub
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Call DPI_Status()
        End Sub
        Private Sub DPI_Status()
            Try
                If My.Computer.Registry.GetValue(reg_key, "dpiawareness", Nothing) Is Nothing Then 'Check if Key Exist
                    'Build key if it does not exist
                    Dim myregkey As RegistryKey = My.Computer.Registry.LocalMachine.CreateSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\devenv.exe\dpiawareness")
                    ' Turn DPIAware on
                    My.Computer.Registry.SetValue(reg_key, "dpiawareness", 0)
                End If
                readValue = My.Computer.Registry.GetValue(reg_key, "dpiawareness", Nothing)
                If readValue = 0 Then ' DPIAware is off
                    RB_NotAware.Checked = True
                    BTN_ChangeStatus.Text = DB_aware
                ElseIf readValue = 1 Then ' DPIAware is on
                    RB_Aware.Checked = True
                    BTN_ChangeStatus.Text = DB_Notaware
                Else
                    MsgBox("Error, Value returned was not a 0 or 1, Press any key")
                End If
            Catch ex As Exception
                MsgBox("error")
            End Try
        End Sub
        Private Sub BTN_Quit_Click(sender As Object, e As EventArgs) Handles BTN_Quit.Click
            Close()
        End Sub
        Private Sub RB_Aware_Click(sender As Object, e As EventArgs) Handles RB_Aware.Click
            Call DPI_Status()
        End Sub
        Private Sub RB_NotAware_Click(sender As Object, e As EventArgs) Handles RB_NotAware.Click
            Call DPI_Status()
        End Sub
    End Class
    Manifest file add
      <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />


    Charlie Soroka

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:09 PM
    Tuesday, February 13, 2018 1:40 AM
  • Hello,

    The following is a reply from another similar post from this morning which I think is valid for your question. And with that you should be considering the client's screen resolution when humanly possible. Set min max width and height when on your development box. The 250%, not much I can say past the information below.

    You might consider the following for scaling. Of course you could design your app to work on a specific display size, incorporate TableLayoutPanels, work with anchors for the controls and Form.AutoSize.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Proposed as answer by Ashidacchi Saturday, February 10, 2018 5:09 PM
    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Friday, February 09, 2018 11:04 PM
    Moderator
  • Exactly how to deal with your current application screen will vary depending on what and how many controls you use.

    Show an image of the app you are refering too and perhaps we can make recommendations.

    The main thing is you need to understand what is happening and how the various alternate control settings work. Also what the 250 percent and the size of the display 3840 pixels really means to you . What is changed and what is not etc.

    There are many recent threads here on the forum.

    Give the first part of this a look over along with the things Karen shows.

    High DPI Desktop Application Development on Windows

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 1:40 AM
  • Hi Karen: Thank you for your reply. I found a program as follows DevEnv Not DPI Aware that turns

    DPI Aware off. I ran DevEnv Not DPI Aware and then called the VB test program and it looked normal in the development environment.  The only problem is when I leave the development environment, I would want to make DPI Aware on. The program DevEnv DPI Aware turn on DPI Aware. I think the  programs works with the registry.  This may be my answer along with your suggestions. 


    Charlie Soroka

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 2:19 AM
  • Hi Karen: Thank you for your reply. I found a program as follows DevEnv Not DPI Aware that turns

    DPI Aware off. I ran DevEnv Not DPI Aware and then called the VB test program and it looked normal in the development environment.  The only problem is when I leave the development environment, I would want to make DPI Aware on. The program DevEnv DPI Aware turn on DPI Aware. I think the  programs works with the registry.  This may be my answer along with your suggestions. 


    Charlie Soroka

    Good to hear that Charlie :-)

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 3:08 AM
    Moderator
  • Hi Karen: I found the registry entry for wpiawareness as follows:
    Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\devenv.exe
    Setting Value to "0" Turns off WPIawareness
    Setting Value to "1" Turns on WPIawareness
    I verfied by setting a 0 or 1 in the registry and then bringing up Visual Studio.
    Now all I need to do is figure out how to read the registry key and also write to the registry key.

    Charlie Soroka

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 9:28 PM
  • Hello Charlie,

    The following does the basics, expects the key to exists which I don't check in the following example. The following link is what I refereed to for writing the code below as it's seldom (years between) I need to write to the registry via code.

    Microsoft docs with nice and to the point code samples. Hope this gets you going with this part of the task :-)

    Public Class Form1
    
        Private hKey As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT" &
            "\CurrentVersion\Image File Execution Options\devenv.exe"
    
        Private hValue As String = "Setting"
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            '
            ' Try to get 'Setting' value
            '
            Dim regObjSettingValue As Object = My.Computer.Registry.GetValue(hKey, hValue, Nothing)
    
            If regObjSettingValue Is Nothing Then
                '
                ' Create the key
                '
            Else
                '
                ' key exists, let's make sure it's a string that represents an integer
                '
                Dim currentValue As Integer = 0
                If Integer.TryParse(regObjSettingValue.ToString, currentValue) Then
                    '
                    ' Here we toggle values from 0 to 1 or 1 to 0
                    '
                    If currentValue = 0 Then
                        currentValue = 1
                    ElseIf currentValue = 1 Then
                        currentValue = 0
                    End If
    
                    '
                    ' Set the value
                    '
                    My.Computer.Registry.SetValue(hKey, hValue, CStr(currentValue))
    
                End If
    
            End If
        End Sub
    End Class
    


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Sunday, February 11, 2018 12:39 AM
    Moderator

All replies

  • Hello,

    The following is a reply from another similar post from this morning which I think is valid for your question. And with that you should be considering the client's screen resolution when humanly possible. Set min max width and height when on your development box. The 250%, not much I can say past the information below.

    You might consider the following for scaling. Of course you could design your app to work on a specific display size, incorporate TableLayoutPanels, work with anchors for the controls and Form.AutoSize.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Proposed as answer by Ashidacchi Saturday, February 10, 2018 5:09 PM
    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Friday, February 09, 2018 11:04 PM
    Moderator
  • Exactly how to deal with your current application screen will vary depending on what and how many controls you use.

    Show an image of the app you are refering too and perhaps we can make recommendations.

    The main thing is you need to understand what is happening and how the various alternate control settings work. Also what the 250 percent and the size of the display 3840 pixels really means to you . What is changed and what is not etc.

    There are many recent threads here on the forum.

    Give the first part of this a look over along with the things Karen shows.

    High DPI Desktop Application Development on Windows

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 1:40 AM
  • Hi Karen: Thank you for your reply. I found a program as follows DevEnv Not DPI Aware that turns

    DPI Aware off. I ran DevEnv Not DPI Aware and then called the VB test program and it looked normal in the development environment.  The only problem is when I leave the development environment, I would want to make DPI Aware on. The program DevEnv DPI Aware turn on DPI Aware. I think the  programs works with the registry.  This may be my answer along with your suggestions. 


    Charlie Soroka

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 2:19 AM
  • Hi Tommy: Thanks for your reply, I found one solution, see reply to Karen. Thank you for your link.

    Charlie Soroka

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 2:24 AM
  • Hi Karen: Thank you for your reply. I found a program as follows DevEnv Not DPI Aware that turns

    DPI Aware off. I ran DevEnv Not DPI Aware and then called the VB test program and it looked normal in the development environment.  The only problem is when I leave the development environment, I would want to make DPI Aware on. The program DevEnv DPI Aware turn on DPI Aware. I think the  programs works with the registry.  This may be my answer along with your suggestions. 


    Charlie Soroka

    Good to hear that Charlie :-)

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 3:08 AM
    Moderator
  • Hi Karen: I found the registry entry for wpiawareness as follows:
    Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\devenv.exe
    Setting Value to "0" Turns off WPIawareness
    Setting Value to "1" Turns on WPIawareness
    I verfied by setting a 0 or 1 in the registry and then bringing up Visual Studio.
    Now all I need to do is figure out how to read the registry key and also write to the registry key.

    Charlie Soroka

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:10 PM
    Saturday, February 10, 2018 9:28 PM
  • Hello Charlie,

    The following does the basics, expects the key to exists which I don't check in the following example. The following link is what I refereed to for writing the code below as it's seldom (years between) I need to write to the registry via code.

    Microsoft docs with nice and to the point code samples. Hope this gets you going with this part of the task :-)

    Public Class Form1
    
        Private hKey As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT" &
            "\CurrentVersion\Image File Execution Options\devenv.exe"
    
        Private hValue As String = "Setting"
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            '
            ' Try to get 'Setting' value
            '
            Dim regObjSettingValue As Object = My.Computer.Registry.GetValue(hKey, hValue, Nothing)
    
            If regObjSettingValue Is Nothing Then
                '
                ' Create the key
                '
            Else
                '
                ' key exists, let's make sure it's a string that represents an integer
                '
                Dim currentValue As Integer = 0
                If Integer.TryParse(regObjSettingValue.ToString, currentValue) Then
                    '
                    ' Here we toggle values from 0 to 1 or 1 to 0
                    '
                    If currentValue = 0 Then
                        currentValue = 1
                    ElseIf currentValue = 1 Then
                        currentValue = 0
                    End If
    
                    '
                    ' Set the value
                    '
                    My.Computer.Registry.SetValue(hKey, hValue, CStr(currentValue))
    
                End If
    
            End If
        End Sub
    End Class
    


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Sunday, February 11, 2018 12:39 AM
    Moderator
  • Hi Karen: Thanks for help on registry code. Copy of Code that will build key if it does not exist
    and turn dpiaware on or off.

    Imports Microsoft.Win32

    Public Class Form1
        Dim reg_key As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\devenv.exe"
        Dim regKey As RegistryKey
        Dim DB_aware As String = "Change Status to DB-AWARE"
        Dim DB_Notaware As String = "Change Status to DB-NotAWARE"
        Dim readValue As Integer
        Private Sub BTN_ChangeStatus_Click(sender As Object, e As EventArgs) Handles BTN_ChangeStatus.Click
            Try
                If My.Computer.Registry.GetValue(reg_key, "dpiawareness", Nothing) Is Nothing Then 'Check if Key Exist
                    MsgBox(reg_key & " Key Not Found, Press any key")
                    Close()
                Else ' Key exist now get value
                    readValue = My.Computer.Registry.GetValue(reg_key, "dpiawareness", Nothing)
                    If readValue = 0 Then
                        My.Computer.Registry.SetValue(reg_key, "dpiawareness", 1)
                    ElseIf readValue = 1 Then
                        RB_Aware.Checked = True
                        My.Computer.Registry.SetValue(reg_key, "dpiawareness", 0)
                    Else
                        MsgBox("Error, Value returned was not a 0 or 1, Press any key")
                    End If
                End If
            Catch ex As Exception
                MsgBox("error")
            End Try
            Call DPI_Status()
        End Sub
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Call DPI_Status()
        End Sub
        Private Sub DPI_Status()
            Try
                If My.Computer.Registry.GetValue(reg_key, "dpiawareness", Nothing) Is Nothing Then 'Check if Key Exist
                    'Build key if it does not exist
                    Dim myregkey As RegistryKey = My.Computer.Registry.LocalMachine.CreateSubKey("SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\devenv.exe\dpiawareness")
                    ' Turn DPIAware on
                    My.Computer.Registry.SetValue(reg_key, "dpiawareness", 0)
                End If
                readValue = My.Computer.Registry.GetValue(reg_key, "dpiawareness", Nothing)
                If readValue = 0 Then ' DPIAware is off
                    RB_NotAware.Checked = True
                    BTN_ChangeStatus.Text = DB_aware
                ElseIf readValue = 1 Then ' DPIAware is on
                    RB_Aware.Checked = True
                    BTN_ChangeStatus.Text = DB_Notaware
                Else
                    MsgBox("Error, Value returned was not a 0 or 1, Press any key")
                End If
            Catch ex As Exception
                MsgBox("error")
            End Try
        End Sub
        Private Sub BTN_Quit_Click(sender As Object, e As EventArgs) Handles BTN_Quit.Click
            Close()
        End Sub
        Private Sub RB_Aware_Click(sender As Object, e As EventArgs) Handles RB_Aware.Click
            Call DPI_Status()
        End Sub
        Private Sub RB_NotAware_Click(sender As Object, e As EventArgs) Handles RB_NotAware.Click
            Call DPI_Status()
        End Sub
    End Class
    Manifest file add
      <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />


    Charlie Soroka

    • Marked as answer by sorokateam Tuesday, February 13, 2018 8:09 PM
    Tuesday, February 13, 2018 1:40 AM
  • Hi Charlie,

    I want to thank you for posting the resolution as I'm sure there are others out there that can benefit from this :-)


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Tuesday, February 13, 2018 8:18 PM
    Moderator