0

We migrate our vb6 project to use sidebyside(regfree) tehnology ....but have problem with dynamic add control to form like:

Private WithEvents tmpCtl As VBControlExtender

Private Sub UserControl_Initialize()
Set tmpCtl = Controls.Add("Project2.UserControl1", "ctl")
  With tmpCtl
    Set .Container = Me
    .Visible = True
  End With
End Sub

and when use tmpCtl object like:

tmpCtl.Properties

we got error "object doesn't support this property or method"

I found that people have like same problem (Strange Case of the missing method: SXS and Controls.Add results in "object doesn't support this property or method"?) and suggestion is implement "Direct user control".

Can somebody know how implement this in vb6 code? How we can fix problem with sxs and dynamic add control to form?

Can give us same example of solution how solve this problem?

bojan
  • 11
  • 2
  • No, Direct Controls typelib approach is viable for 1st party ComCtls from MS, not for your just compiled user-controls which are a moving target regading CLSIDs/IIDs. Try `tmpCtl.object.Properties` instead or even better: `Dim oCtl As UserControl1 : Set oCtl = tmpCtl.object` and then `oCtl.Properties` should be available as well. – wqw Sep 02 '19 at 10:35
  • Thank you for answer, but we have big VB6 project i wich is very dificult change all postions where use VBControlExtender without .object property. My idea is create one tlb file with all refrence controls and all controls load on strat of program. What you think for that idea? Another big problem is that we can not debug vb6 project in regfree mode where we can see error places and where we need add .object property. – bojan Sep 02 '19 at 13:29
  • `tmpCtl.Properties` is wrong on many levels. It would fail with regular (non-regfree) COM when your user-controls are in a separate OCX project (or in current project, can't remember which way it was) too. Don't think there is something simple with regfree COM that you are missing which will make your current code run again w/ no modifications. – wqw Sep 02 '19 at 15:00
  • Did you know how i can debug vb6 project in regfree mode? I add manifest file in program files(c:\Program Files (x86)\Microsoft Visual Studio\VB98\) folder but did not work... – bojan Sep 03 '19 at 09:09
  • @bojan debugging is a very broad topic. You could post another question with more specifics, maybe. – StayOnTarget Sep 03 '19 at 11:27

0 Answers0