?
Solved

Resize picture for a MSFlexGrid cell

Posted on 2000-03-25
5
Medium Priority
?
3,466 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 28

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 28

Accepted Solution

by:
Ark earned 300 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…
Suggested Courses

755 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