Control placements don't seem to compute

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jrmourning
    New Member
    • Jul 2012
    • 4

    Control placements don't seem to compute

    I am studying basic visual basics graphics.

    Form1 size is 500, 500. (Of course, location is 0, 0)

    Textbox1 size is 100, 100

    Textbox1 Location is 400, 400.

    Can anyone tell me why the lower right corner of the text box does not coincide with the lower right corner of Form1?
    Last edited by jrmourning; Sep 11 '12, 03:31 PM. Reason: typo
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    First of all: a pixel is 15 twip.
    So if you want to work on the precise pixel, you have to use a multiple of 15 like :
    480 or 505 for the form
    90 or 105 for top and left
    390 or 405 for the textbox.
    Also don't forget to set the border of the form to NONE , the Controlbox to false and nothing in the Caption.

    Comment

    • jrmourning
      New Member
      • Jul 2012
      • 4

      #3
      Thank you. It is very kind of you to answer a beginner's question. After playing with the factors you gave me I now understand why I was not getting the anticipated placement.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Guido, doesn't the twips-per-pixel ratio depend on screen size and/or resolution? Haven't played with it for a bit.

        I know it's usually 15, but to be safe I always use Screen.TwipsPer PixelX and Screen.TwipsPer PixelY rather than hard-coding.

        Admittedly, it may seem silly trying to future-proof code written in a twelve-year-old programming language.

        (Note, in many cases you can avoid the whole issue by setting ScaleMode to 3 - Pixel.)

        Comment

        • Guido Geurs
          Recognized Expert Contributor
          • Oct 2009
          • 767

          #5
          Killer42,
          I don't think twips-per-pixel depends on screen.
          The definition of twips in the help of VB:
          "A screen-independent unit used to ensure that placement and proportion of screen elements in your screen application are the same on all display systems. ..."
          But yes, it's better to work with "3-Pixel" as scalemode in the form settings.

          Comment

          Working...