PRB: Syntax Error with ActiveX Control Terminates VFPLast reviewed: January 10, 1997Article ID: Q156505 |
The information in this article applies to:
SYMPTOMSThe ImageList ActiveX control is used to store a set of images for use with other ActiveX controls. When setting the Picture property of an ActiveX control to an image in the ImageList control, the following error may occur:
This Program has performed an illegal operation and will be shut down CAUSEThe Picture property may have been omitted from the reference to the ImageList control.
STATUSMicrosoft is researching this behavior and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe ImageList ActiveX control allows you to load all the .bmp files and .ico files that may be needed for other ActiveX controls. You can then set the Picture property of an ActiveX control to reference any of the images in the ImageList control. The following command is an example of assigning the first image to the Picture property of an ActiveX control:
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:
This Program has performed an illegal operation and will be shut down Steps to Reproduce BehaviorThe following program demonstrates the correct and incorrect way to change a Picture Property of an ActiveX control using an image from the ImageList control.
***** 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.
REFERENCESFor more information on the ActiveX controls that shipped with Visual FoxPro 5.0, see Help and the Ctrlref.hlp file located in the Vfp\Ctrlhlp directory.
|
KBCategory: kbprg kbprb
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |