Solved

Auto resizing a picture to fit

Posted on 2003-11-24
7
252 Views
Last Modified: 2012-05-04
Hi,
When I load a picture into a picture object, it's too big and is truncated to the right and bottom. So I am trying to re-size it.
I tried 2 things:
1. Picture.AutoSize = true
It complains that "Method or data member not found". I am using VB6.

2. A solution I found at this site:
Dim AspectRatio As Single
Dim NewHeight As Long
Dim TmpPic As StdPictureSet Picture1.Picture = LoadPicture("pic")

AspectRatio = TmpPic.Width / TmpPic.Height
NewHeight = Picture1.ScaleWidth / AspectRatio

Picture1.AutoRedraw = True    ' Necessary to keep the picture from being erased when window gets repainted
Picture1.PaintPicture TmpPic, 0, (Picture1.ScaleHeight - NewHeight) / 2, Picture1.ScaleWidth, NewHeight
' Arguments are as follows:   Source picture, Destination X, Destination Y, New Width, New Height

It also complains that "Method or data member not found" at Picture1.ScaleWidth

Thank you for your help.
Phil
0
Comment
Question by:spoowiz
7 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 9813970
picture1.autosize = true should work
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 9813981
oh and you may need this:

Picture1.autoRedraw = true
Picture1.autosize = true
0
 

Author Comment

by:spoowiz
ID: 9814029
I was using the wrong object. Please ignore this question. Sorry.
How do I delete this question?
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:spoowiz
ID: 9814079
p.s. fyi to anyone who can use this:

option 1 picture1.autosize = true did not work.
option 2 does
0
 
LVL 2

Expert Comment

by:robbrownuk
ID: 9814397
To delete - post a 0 point question in the Community Support forum at:

http://experts-exchange.com/Community_Support/


PS: Don't Accept this as an answer!

robbrownuk
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 9831776
PAQed, with points refunded (250)

Computer101
E-E Admin
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now