Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Dpi-Aware experiments in V.S. 2005 Environment

Dpi-Aware experiments in V.S. 2005 Environment

Scheduled Pinned Locked Moved Mobile
csharpgraphicswindows-adminlearningworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hurricane3000
    wrote on last edited by
    #1

    Hi all, I written the following code to make "DPI-Aware" the ImageSize property of an ImageList Control in my application (V.B. .Net C.F.2) in V.S. 2005 environment: Dim RK As Microsoft.Win32.RegistryKey = _ Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Drivers\Display\GPE") Dim LPX As String = CType(RK.GetValue("LogicalPixelsX"), String) Dim LPY As String = CType(RK.GetValue("LogicalPixelsY"), String) If LPX = 96 And LPY = 96 Then Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16) Else Me.ImageList1.ImageSize = New System.Drawing.Size(32, 32) End If Well, I placed it in the Form1_Load event, and it works. But with doubt if that place was the "rigth place", I tryed to place it in the "Form1.Designer.vb" code (because I think it is the "more appropriate" place). I placed the first 3 line in the begin of code: <global.microsoft.visualbasic.compilerservices.designergenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form Dim RK As Microsoft.Win32.RegistryKey = _ Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Drivers\Display\GPE") Dim LPX As String = CType(RK.GetValue("LogicalPixelsX"), String) Dim LPY As String = CType(RK.GetValue("LogicalPixelsY"), String) 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) and the "If-Else" conditions immediately above the ImageList.Add property code: If LPX = 96 And LPY = 96 Then Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16) Else Me.ImageList1.ImageSize = New System.Drawing.Size(32, 32) End If Me.ImageList1.Images.Clear() Me.ImageList1.Images.Add(CType(resources.GetObject("resource"), System.Drawing.Image)) Me.ImageList1.Images.Add(CType(resources.GetObject("resource1"), System.Drawing.Image)) Me.ImageList1.Images.Add(CType(resources.GetObject("resource2"), System.Drawing.Image)) Also if it's recomanded to not write code-lines directly in .Designer.vb code, the code works correctly in both emulator and device, BUT sometime (I not understood why and in witch circumstances), only the If-Else conditions lines above are deleted and replaced with the single line: Me.ImageList1.ImageSize = New System.Drawing.Size

    J 1 Reply Last reply
    0
    • H Hurricane3000

      Hi all, I written the following code to make "DPI-Aware" the ImageSize property of an ImageList Control in my application (V.B. .Net C.F.2) in V.S. 2005 environment: Dim RK As Microsoft.Win32.RegistryKey = _ Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Drivers\Display\GPE") Dim LPX As String = CType(RK.GetValue("LogicalPixelsX"), String) Dim LPY As String = CType(RK.GetValue("LogicalPixelsY"), String) If LPX = 96 And LPY = 96 Then Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16) Else Me.ImageList1.ImageSize = New System.Drawing.Size(32, 32) End If Well, I placed it in the Form1_Load event, and it works. But with doubt if that place was the "rigth place", I tryed to place it in the "Form1.Designer.vb" code (because I think it is the "more appropriate" place). I placed the first 3 line in the begin of code: <global.microsoft.visualbasic.compilerservices.designergenerated()> _ Partial Public Class Form1 Inherits System.Windows.Forms.Form Dim RK As Microsoft.Win32.RegistryKey = _ Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Drivers\Display\GPE") Dim LPX As String = CType(RK.GetValue("LogicalPixelsX"), String) Dim LPY As String = CType(RK.GetValue("LogicalPixelsY"), String) 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() End If MyBase.Dispose(disposing) and the "If-Else" conditions immediately above the ImageList.Add property code: If LPX = 96 And LPY = 96 Then Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16) Else Me.ImageList1.ImageSize = New System.Drawing.Size(32, 32) End If Me.ImageList1.Images.Clear() Me.ImageList1.Images.Add(CType(resources.GetObject("resource"), System.Drawing.Image)) Me.ImageList1.Images.Add(CType(resources.GetObject("resource1"), System.Drawing.Image)) Me.ImageList1.Images.Add(CType(resources.GetObject("resource2"), System.Drawing.Image)) Also if it's recomanded to not write code-lines directly in .Designer.vb code, the code works correctly in both emulator and device, BUT sometime (I not understood why and in witch circumstances), only the If-Else conditions lines above are deleted and replaced with the single line: Me.ImageList1.ImageSize = New System.Drawing.Size

      J Offline
      J Offline
      Joel Ivory Johnson
      wrote on last edited by
      #2

      You had it right the first time with placing the code in Form_Load. The designer section of the code is "owned" by Visual Studio and as you've seen VS does not gaurantee that changes you make to it will be preserved. If you plan to have others use and modify your code then the designer area isn't idea because no one else would know to look there for your code. Other than the Form_Load method the other place to consider would be in the constructor of the form right after the InitializeComponent method is called.

      Joel Ivory Johnson

      Meet my dev team: RDA Architecture Evangelist Team Blog

      My site: J2i.net

      Twitter: J2iNet

      H 1 Reply Last reply
      0
      • J Joel Ivory Johnson

        You had it right the first time with placing the code in Form_Load. The designer section of the code is "owned" by Visual Studio and as you've seen VS does not gaurantee that changes you make to it will be preserved. If you plan to have others use and modify your code then the designer area isn't idea because no one else would know to look there for your code. Other than the Form_Load method the other place to consider would be in the constructor of the form right after the InitializeComponent method is called.

        Joel Ivory Johnson

        Meet my dev team: RDA Architecture Evangelist Team Blog

        My site: J2i.net

        Twitter: J2iNet

        H Offline
        H Offline
        Hurricane3000
        wrote on last edited by
        #3

        Thank you very much Joel!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups