?
Solved

Resize picture for a MSFlexGrid cell

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…
Suggested Courses

765 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