This article was previously published under Q189914
This article has been archived. It is offered "as is" and will no longer be updated.
When you wrap the CoolBar control inside a Visual Basic ActiveX Control,your Visual Basic client EXE may gave an Illegal Operation error when itshuts down. This occurs only on Windows 95, Windows 98, or Windows Me, and when the CoolBar controlhas child controls in a band. You will get the following error only in acompiled EXE and not in the Visual Basic IDE:
"This program has performed an illegal operation and will be shut down"
Clear all the bands from the CoolBar control before the client EXE shutsdown. See Steps to Reproduce Behavior below for an example.
Microsoft has confirmed this to be a bug in the Microsoft productslisted at the beginning of this article. We are researching thisbug and will post new information here in the Microsoft KnowledgeBase as it becomes available.
To reproduce this behavior you must build an OCX that wraps the CoolBarcontrol and a client EXE that uses that OCX. The EXE must be run on Windows 95, Windows 98, or Windows Me. The EXE will not give the above error running on NT 4.0 or Windows 2000.
Steps to Reproduce Behavior
Create a new ActiveX Control Project.
Using the Projects menu, select Components to bring up the Components dialog box. On the Controls Tab, check "Microsoft Windows Common Controls-3." Click OK to close the Components window.
Place a CoolBar on the UserControl.
Change the name of the UserControl to "ctlCoolBar", and the project name to pjxCoolBar.
Place a TextBox, CommandButton, and ComboBox on the CoolBar control.
Alternate mouse click on the CoolBar and select Properties from the pop-up menu.
On the Property Pages dialog box, select the Bands tab.
For Index 1, set the Child property to Text1; for Index 2, set the Child property to Command1; for Index 3, set the Child property to Combo1.
Add the following code to the UserControl:
Public Sub ClearBands() ' clearing all the bands before the control terminates ' will keep the client EXE from having the Illegal Operation ' error when it shuts down CoolBar1.Bands.Clear End Sub
From the File menu, Save the project, and Make pjxCoolBar.OCX.
Create a new Standard EXE Project. Form1 is created by default.
Using the Projects menu, select Components to bring up the Components dialog box. On the Controls tab, check PjxCoolBar. Click OK to close the dialog window.
Place the ctlCoolBar control on Form1.
From the File menu, Save the project, and Make project1.exe.
Run project1.exe and then shutdown project1.exe. You will get the Illegal Operation error.
To work around the error, add the following code to the Form's QueryUnload event:
Repeat steps 14 and 15. You will not get the error when you shut down project1.exe.
Microsoft Visual Basic 6.0 Learning Edition, Microsoft Visual Basic 6.0 Professional Edition, Microsoft Visual Basic 5.0 Professional Edition, Microsoft Visual Basic 6.0 Enterprise Edition, Microsoft Visual Basic 5.0 Enterprise Edition