• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2619
  • Last Modified:

Debug OCX used within another application

I'm using VB6 and have the code to an OCX.  I've tried setting the Version Compatibility with the Component tab of the Project Properties to all three types (No Compatibility, Project Compatibility, and Binary Compatibility).  I've also set within the Debugging tab to Start Program and pointed it to the program that uses the OCX.  When I try to debug the process the program that uses the OCX informs me that the component is not registered.  If I re-register it and run the program outside of VB everything works fine.  If I then try again to debug from inside of VB I get the registration error.  It seems that VB is somehow overwriting the registry settings and pointing to VB6DEBUG.DLL instead of my OCX.

What do I need to do to properly debug the OCX?

Thanks
0
tarang
Asked:
tarang
  • 4
  • 2
1 Solution
 
inthedarkCommented:
After you create the OCR is must be registered using regsvr32.  (Normally after it has been moved to the system32 folder.) If the OCX has already be registered in the wrong location it needs to be unregistered first.

I found that it was better to add the source code for the OCX into my other VB projects, in this way you don't have to worry about version management. I also found that say you have 50 terminals on a network, by embedding the usercontrol  into you main application you can simple recreate the exe making upgrade deployment simple.

Another reason for embedding the usercontrol in your main app is that you cannot change the OCX once it has been used. So you need create create with a different version, MyControlV10.OCX, then MyControlV11.OCX.  If you screw up you can find that when you open an application from the VB IDE, if you open a form that uses the OCX if the version nuumbers are wrong the control gets converted to a picture box. So you need to delete the picture box set a reference to the new OCX and rebuild all of the properties for the OCX. But by keeping the control in your main application all of these problems just went away....bliss...leaving you with stacks more time for golf, drinking, lying in the sun or whatever you do when not slumped over a computer :~)
0
 
inthedarkCommented:
OCX hell, been there! Done that! Aint going back!
0
 
tarangAuthor Commented:
The OCX is registered using regsvr32 and works fine if is start the program which instantiates the OCX from outside of the VB IDE.  Only when the program is launched inside the VB IDE - in order to debug the OCX, does the program complain about not being able to load the OCX.  I found that if I start the program normally and then attach to the process using Visual C/C++ 6.0's IDE that I can debug the OCX although I can only see simple variables and not objects.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
inthedarkCommented:
To debug OCX....

1) Have you tried renaming the OCX project?  Like MyControlV12.

2) Normally what I do is load the Test Project, then in the VB IDE you can click on file, Add Project

3)  In your Test Project you need to set the componants to use MyControlV12.

4) In the MyControlV12 you need to set the project properties debugging tab to wait for objects to be created.

5) It is important not to compile the project but just run the project.

6) In the test projects open the form to be used for testing, it may complain about not fiunding the control don't panic its normal.  Delete any old control reference (it probably got converted to a picture box anyway). The new control should be in the toolbar, click it and create the new control on your form.  It is best to setup the control properties in the form load.

Be aware that your ocx software is running all of the time, even when your are in design mode. You can tell which mode you are in I think it is the ambientchanged event So it is best to close any OCX windows before you add control to your form.


You can detect if your are in design mode. The following shows how to handle difference. So that in design mode you get some kind of image on the control.

Private Sub UserControl_AmbientChanged(PropertyName As String)
zHandleModeChange
End Sub

Private Sub zHandleModeChange()
On Error Resume Next
Dim bAmbient As Boolean
bAmbient = Ambient.UserMode
Dim bEnable As Boolean

If bAmbient And mbVisible Then
    bEnable = True
End If

timSelection.Enabled = bAmbient
timEastWest.Enabled = bAmbient


'Timer1.Enabled = bEnable
timResize.Enabled = bAmbient
timLabels.Enabled = bAmbient

End Sub

Private Sub UserControl_Paint()

If Not Ambient.UserMode Then

    ' create a dsign time image for the control
    UserControl.Cls
    UserControl.BackColor = RGB(100, 100, 200)
    Dim lc
    lc = 10
    Do While lc < UserControl.ScaleWidth
        UserControl.Line (lc, 0)-(lc, UserControl.ScaleHeight), 0, BF
        lc = lc + 10
    Loop
    lc = 10
    Do While lc < UserControl.ScaleHeight
        UserControl.Line (0, lc)-(UserControl.ScaleWidth, lc), 0, BF
        lc = lc + 10
    Loop
Else
     ' create a live image for the control (if required)
    If mbDebugMode Then zDM "UserControl_Paint"

End If
End Sub
0
 
tarangAuthor Commented:
Yes that's fine I tried doing some of the things that inthedark suggested but since I don't actually have a lot of the sorce code I can't do all of the things and get it to work within VB.

Thanks any ways inthedark.

Tarang
0
 
inthedarkCommented:
You need to contact the people that supplied to the OCX.  If you have a genuine legal copy of the OCX you can force the supplier to either fix the problem or send you the source code.  
0
 
GranModCommented:
PAQed with points refunded (125)

GranMod
Community Support Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now