By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,578 Members | 986 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,578 IT Pros & Developers. It's quick & easy.

Photo slide show in VB6

P: 1
Hello,

I'm trying to make a photo slide show in VB6. I'm trying to get the right size for my pictures, they have to fill up the screen entirely. It works with the first picture. But when a picture has another resolution it gets the same shape as the picture that was showed before.

I've got this so far:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.   Timer1.Interval = 1000
  3.   Timer1.Enabled = True
  4. End Sub
  5.  
  6.  
  7. Private Sub Timer1_Timer()
  8.   Dim X As Integer
  9.   Dim Y As Integer
  10.   Dim A As Double
  11.   Dim B As Integer
  12.  
  13.   gX = gX + 1 
  14.   ' (gX is in a module like this: Public gX as Integer)
  15.  
  16.   X = 0
  17.   Y = 0
  18.   A = 0
  19.   B = 0
  20.  
  21.   Image1.Picture = LoadPicture("C:\Documents and Settings\Jeroen\Mijn documenten\mijn afbeeldingen\Foto diashow\" & gX & ".jpg")
  22.   'You will get the image dimensions in pixels. to get them in Twips scale, remove
  23.   ' the "/ Screen.TwipsPerPixelY" and "/ Screen.TwipsPerPixelX"  below.
  24.   ' MsgBox "Image Height: " & Image1.Height / Screen.TwipsPerPixelY & "Image width: " & Image1.Width / Screen.TwipsPerPixelX
  25.  
  26.   X = Image1.Height
  27.   Y = Image1.Width
  28.  
  29.   Image1.Stretch = True
  30.  
  31.   If X < Y Then
  32.  
  33.     ResWidth = Screen.Width \ Screen.TwipsPerPixelX
  34.     ResHeight = Screen.Height \ Screen.TwipsPerPixelY
  35.  
  36.     'A = ResHeight
  37.     B = ResWidth
  38.  
  39.     A = (ResWidth * Image1.Height) / Y
  40.  
  41.     Image1.Height = A * 15
  42.     Image1.Width = B * 15
  43.  
  44.   Else
  45.  
  46.     ResWidth = Screen.Width \ Screen.TwipsPerPixelX
  47.     ResHeight = Screen.Height \ Screen.TwipsPerPixelY
  48.  
  49.     A = ResHeight
  50.     'B = ResWidth
  51.  
  52.     B = (ResHeight * Image1.Width) / X
  53.  
  54.     Image1.Height = A * 15
  55.     Image1.Width = B * 15
  56.  
  57.   End If
  58.  
  59. End Sub

Can anybody help me?
Aug 19 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
Is Image1.Stretch True or False at design time? If it's False, then X and Y are being set differently for the first image than for any subsequent ones.
Aug 21 '07 #2

Post your reply

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