Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Auto resizing a picture to fit

Posted on 2003-11-24
7
255 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

829 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