Results 1 to 4 of 4

Thread: Resizing picture boxes

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    45

    Angry

    Hi All,

    I'm trying to resize a picture box to a particular size (in pixels). In theory, what I need to do is this :
    Code:
    Picture.Height = Picture.ScaleY(NewHeight, Picture.ScaleMode, vbPixels)
    Picture.Width = Picture.ScaleX(NewWidth, Picture.ScaleMode, vbPixels)
    or I should be able to multiply the NewHeight or NewWidth by Screen.TwipsPerPixelX / Y. Both give me inaccurate results!

    Screen.TwipsPerPixel returns (as far as I can see) an integer (15 on my machine). Setting scaleMode to vbPixels on the picture box and manually resizing until I get a 100 pixel high box gives a 1560 high twip box. This would seem to indicate that twips per pixel is rounded (odd numbers round down remember) to the nearest integer. Is there a better way to do this??? I've tried everything I can think of to get the damn thing to work but it always seems to give me the wrong size. Any help will REALLY be appreciated!

    K

  2. #2
    Member
    Join Date
    May 2000
    Posts
    41

    Smile possible help...

    I had the same problem once and then I read that if you change the values of .scalex or .scaley (or any .scale???) it changes the mode to user defined which totally screwed up my output (which seems to be the same thing occuring to you). The solution was to not use the .scalex, .scaley, .. but to change the values of the height, width, top, left directly. this stopped the mode from auto switching to 'user' and let the twip return the correct numbers.

    hope this helped as i know it did help me.

    now if i can get someone that knows about NT rights to help me we would both be happy =)
    Here I doeh again

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You're on the right track using the ScaleX, ScaleY methods, but the problem is what you're using for the From and To value for the Scaling.

    A Picturebox's Width and Height is going to be measured in whatever the ScaleMode of the Parent is, so try this:
    Code:
    Picture1.Width = Picture1.ScaleX(NewWidthInPixels, vbPixels, Picture1.Parent.ScaleMode)
    Picture1.Height = Picture1.ScaleY(NewHeightInPixels, vbPixels, Picture1.Parent.ScaleMode)
    Regards,

    - Aaron.

  4. #4

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    45

    Cool

    Thanks to you both, but I'm afraid it was neither of those two things

    It apppears the the picturebox has a 'border'. To find it you need to set the scale mode of the picture box to twips and subtract the scaleX/Y from the width/height. In theory this should give you zero, but it doesn't. This is the border width and needs to be added to get accurate sizes.

    Code:
    Picture1.ScaleMode = vbTwips
    borderX = Picture1.Width - Picture1.ScaleWidth
    borderY = Picture1.Height - Picture1.ScaleHeight
    Thanks anyway

    K

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