Article ID: 156505
Article Last Modified on 10/15/2003
ThisForm.Olecontrol1.Object.Picture = ;
ThisForm.Olecontrol2.Object.ListImages(1).Picture
If the Picture property is omitted from the end of the reference, the
following error message occurs:
***** Start Code *****
PUBLIC frmOcxTest
frmOcxTest = CREATEOBJECT('Form1')
frmOcxTest.ADDOBJECT("PicList1","PicList", ;
"COMCTL.ImageListCtrl.1")
* Add the Fox.bmp to the image control
frmOcxTest.PicList1.Object.ListImages.Add ;
(,,LoadPicture("C:\VFP50\FOX.BMP"))
frmOcxTest.ADDOBJECT("OcxButton1","OcxButton", ;
"Threed.SSCommand")
frmOcxTest.OcxButton1.Caption = "Change Image Works"
frmOcxTest.ADDOBJECT("Button1","Button")
frmOcxTest.Show()
DEFINE CLASS Form1 AS Form
Top = 0
Left = 0
Height = 300
Width = 300
Name = "Form1"
Caption = "ImageList Test"
ENDDEFINE
DEFINE CLASS PicList AS OLEControl
ENDDEFINE
DEFINE CLASS OcxButton AS OLEControl
Top = 75
Left = 75
Height = 80
Width = 150
Visible = .T.
PROCEDURE Click
* This code will change the image on the ActiveX Button
ThisForm.OcxButton1.Object.Picture = ;
ThisForm.PicList1.Object.ListImages(1).Picture
ENDPROC
ENDDEFINE
DEFINE CLASS Button AS CommandButton
Top = 195
Left = 75
Height = 27
Width = 150
Visible = .T.
Caption = "Change Image Fails"
PROCEDURE Click
* This code will cause the following error message:
* "This Program has performed an illegal operation and will be
* shut down" (There is no "Picture" reference after "ListImages".)
ThisForm.OcxButton1.Object.Picture = ;
ThisForm.PicList1.Object.ListImages(1)
ENDPROC
ENDDEFINE
***** End Code *****
When you run the above code, the "Change Image Works" button displays the
Fox.bmp file from the ImageList control. The "Change Image Fails" button
causes an "Invalid Page Fault" error.
Keywords: KB156505