471,066 Members | 1,200 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Stretching the Image on MDI Form

Hi Folks,

I Want regarding the stretching image on the MDI Form?

I have one MDI Form and there is a image on that form? so that i want to stretch the image on the form according to the screen resoluation? these are the requriments i have? so please help me urgently.

Thanks & Regards
---------------------------
Mahesh
Feb 8 '08 #1
2 4552
Bum
19
Hi Mahesh,

Look at

Screen.TwipsPerPixelX
Screen.TwipsPerPixelY

You get the size of your screen this way.

if you want, you can do below, add three pictureboxes to mdiform adn make them the same size as the mdiform like

picture1.height = mdiform1.height
picture1.width= mdiform1.width

Expand|Select|Wrap|Line Numbers
  1. Public Sub Setup_Image(FileName)
  2.  
  3.   'picture1 is the main interface
  4.   'picture2 holds the original picture
  5.   'picture3 holds the resized image and transfers it to picture1
  6.  
  7.   'everyones in twips
  8.     Picture1.ScaleMode = 3
  9.     Picture2.ScaleMode = 3
  10.     Picture3.ScaleMode = 3
  11.     Me.ScaleMode = 3
  12.  
  13.     'assign our pic
  14.     Picture2.Picture = LoadPicture(FileName)
  15.  
  16.     HW = 600 'height/width 'size of our square
  17.     Picture1.Width = HW
  18.     Picture1.Height = HW
  19.     Picture3.Width = HW
  20.     Picture3.Height = HW
  21.  
  22.     'find out if the pic is tall or fat then scale to fit in box, then center
  23.      MyWidth = Picture2.Picture.Width
  24.      MyHeight = Picture2.Picture.Height
  25.  
  26.    ''find out if wider or taller, then find ratio
  27.    If MyHeight >= MyWidth Then
  28.       myRatio = MyWidth / MyHeight
  29.       MyHeight = HW
  30.       MyWidth = MyHeight * myRatio
  31.       LeftBound = (HW - MyWidth) / 2
  32.       TopBound = 0
  33.    Else
  34.       myRatio = MyHeight / MyWidth
  35.       MyWidth = HW
  36.       MyHeight = MyWidth * myRatio
  37.       LeftBound = 0
  38.       TopBound = (HW - MyHeight) / 2
  39.    End If
  40.  
  41.     Picture1.AutoRedraw = True
  42.     Picture3.AutoRedraw = True
  43.     Picture3.Cls
  44.  
  45.     Call Picture3.PaintPicture(Picture2.Picture, _
  46.                                 LeftBound, TopBound, MyWidth, MyHeight)
  47.     Picture3.Line (LeftBound, TopBound)-(MyWidth + LeftBound, MyHeight + TopBound), , B
  48.  
  49.     Picture1.Picture = Picture3.Image
  50.  
  51. End Sub

Hope this helps,

B
Feb 14 '08 #2
Killer42
8,435 Expert 8TB
mahesh123, what version of VB are you using?
Feb 15 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

22 posts views Thread by Kim Scarborough | last post: by
1 post views Thread by Jax | last post: by
3 posts views Thread by Raed Sawalha | last post: by
4 posts views Thread by Arthur Dent | last post: by
2 posts views Thread by elephant | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.