Solved

Resize picture for a MSFlexGrid cell

Posted on 2000-03-25
5
3,169 Views
Last Modified: 2013-12-25
First of all... Thank You for taking the time to review this post.
I have been trying to find a way to resize a .GIF or .BMP image, and place the resized image in a cell location within a row of a MSFlexGrid - But No Luck!.

I have tried a LoadPicture event of a PictureBox with AutoSize=TRUE (this is to get the proper full size initially), then I PaintPicture in another PictureBox with the .Width & .Height amounts changed as needed. This looks great, but when I try to put the resized image of the second PictureBox using a "Set MSFlexGrid.CellPicture = PictureBox2.Picture" (the image does NOT appear in the cell!) I have tried doing "SET MSFlexGrid.CellPicture = PictureBox1.Picture" (and that displays ok - but it is the original image size), and finanly I discovered this is the same as doing a "Set MSFlexGrid.CellPicture = LoadPicture("C:\Images\filename.Gif")

I have tried many different variations of the above, including using a Image Control and the Stretch, but when it comes time for the ".CellPicture" It just doesnt want to work for me!

*** SAMPLE CODE I HAVE TRIED ***
Picture1.AutoSize = True
Picture1.Picture = LoadPicture("C:\Images\filename.Gif")
sngPctDiff = .75

Picture2.AutoSize = False
Picture2.Width = Picture1.Width * sngPctDiff
Picture2.Height = Picture1.Height * sngPctDiff
Picture2.PaintPicture Picture1.Picture, 0, 0, Picture1.Width * sngPctDiff, Picture1.Height * sngPctDiff

With MSFlexGrid
.Row = 1
.Col = 0
Set .CellPicture = Picture2.Picture
End With


Any suggestions would be much appreciated - Thanks again for taking the time to read this - maybe you have an idea I can try?.

John ("I feel my hair turning more grey by the minute") Mc.



0
Comment
Question by:JM65
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:Ark
ID: 2660186
Hi
Very easy
After painting picture2 add
Picture2.Picture = Picture2.Image
' or
' Set .CellPicture = Picture2.Image
Cheers
0
 

Author Comment

by:JM65
ID: 2661085
Thank You ARK!
That did the trick - I just forgot to include that last line of code.
0
 
LVL 27

Accepted Solution

by:
Ark earned 75 total points
ID: 2661934
Glad to help you. BTW, you can use Image control with stretch property set to True to resize your picture.
Private Sub Command1_Click()
  Dim stdPic as stdPicture
  Dim d as Single
  Set stdPic = LoadPicture("C:\Images\filename.Gif")
  d = 0.75
  Image1.Width = ScaleX(stdPic.Width, vbHimetric, vbTwips) * d
  Image1.Height = ScaleY(stdPic.Height, vbHimetric, vbTwips) * d
  Image1.Stretch = True
  Image1.Picture = stdPic
  With MSFlexGrid
   .Row = 1
   .Col = 0
   Set .CellPicture = Image1.Image
  End With
End Sub
Cheers

0
 

Expert Comment

by:TonyJYoung
ID: 13864633
I tried all the above methodologies and have a couple of comments:

First the Image1.Image suggested in the last submission I can't get to work as the Image control doesn't seem to have an Image property

Second, I've tried the other method of paintpicture, etc and all I get is a 'grey' shaded image, the real image I want 'pops' up in the Picture box (picture2) but then vanishes.

Any comments?

TonyJYoung
0
 

Expert Comment

by:TonyJYoung
ID: 13872440
Okay, setting .AutoRedraw to True solves the grey image bit, but each image when added to the grid chnages all the prior images to the current (last) image loaded. I have set FillStyle to flexFillSingle.

Any ideas?

TonyJYoung
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

762 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

16 Experts available now in Live!

Get 1:1 Help Now