Solved

Resize picture for a MSFlexGrid cell

Posted on 2000-03-25
5
3,284 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
[X]
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
  • 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 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