Solved

Create Image Object at run time

Posted on 2010-11-09
3
1,069 Views
Last Modified: 2012-05-10
I want to add images as needed at run time to a form.  I tried:
x=createobject('Image')
x.name='image2'
x.picture='c:\discipline.bmp'
x.left=25
x.Top=25
x.height=20
x.Width=20
x.visible=.t.

No error is generated nor does my image appear.
Can this be done?
0
Comment
Question by:wcsoctu
  • 2
3 Comments
 
LVL 41

Expert Comment

by:pcelba
ID: 34097757
The Image object must be on some form, try e.g. following code:


PUBLIC oForm

oForm = CREATEOBJECT("ImageForm")

oForm.Visible = .T.

*oForm.Image2.PictureVal = cImg.exp  && Image in Memo field

oForm.Image2.Picture = 'c:\discipline.bmp'





DEFINE CLASS ImageForm AS Form

  

  ADD OBJECT Image2 AS Image ;

      WITH Top = 0, Left = 0, ;

           Height = 300, Width = 500, ;

           Stretch = 2



ENDDEFINE

Open in new window

0
 
LVL 41

Accepted Solution

by:
pcelba earned 500 total points
ID: 34097786
You may also create object in the screen window (same code is possible to use in any other form):

_screen.AddObject('image1','Image')

_screen.image1.Top = 0

_screen.image1.Left = 0

_screen.image1.height = 300

_screen.image1.width = 300

_screen.image1.stretch = 2

_screen.Image1.Picture = 'c:\discipline.bmp'

_screen.image1.visible = .t.

Open in new window

0
 
LVL 4

Author Comment

by:wcsoctu
ID: 34098338
Using your second example with thisform instead of _screen I was able to accomplish it.  I want to add an unknown number of images at run time.   Thank You
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Annoying text scroll in Textbox 10 80
Save Table Settings 6 259
Can't Build Exe in VFP9 8 311
convert/ import XLSB / vfp9 5 70
Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

19 Experts available now in Live!

Get 1:1 Help Now