Solved

Resize picture for a MSFlexGrid cell

Posted on 2000-03-25
5
3,263 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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 While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

832 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