Antwise community forums
VB6: How to create an Antview control dynamically? - Printable Version

+- Antwise community forums (https://forums.antwise.com)
+-- Forum: Antview (https://forums.antwise.com/forumdisplay.php?fid=11)
+--- Forum: Antview for Windows (https://forums.antwise.com/forumdisplay.php?fid=12)
+--- Thread: VB6: How to create an Antview control dynamically? (/showthread.php?tid=204)



VB6: How to create an Antview control dynamically? - AlKalm - 2024-11-12

Hello, programmers!

I need to dynamically create Antview controls becose of function to open and close some number of web views with the tab-control.

I have try some code, but it give the error message only: Type mssmatch!

Code:
Public Function MakeTheAnt()   Dim oCtrl As Object   Dim oAntview As Antview   'Or Dim oAntView As AntViewAx2.Antview     Set oCtrl = Controls.Add("AntViewAx2.Antview", "oCtrl")   Set oAntview = oCtrl.object '->Error: Type missmatch     'Or Set oAntview = CreateObject( "AntViewAx2.Antview", "") '->Error: Type missmatch End Function

Any idea?.. Huh


RE: VB6: How to create an Antview control dynamically? - wila - 2024-11-12

Hello AlKalm,

We just tested it here for the AntView2 control and the following code worked for us.
Code:
Public WithEvents EdgeBrowser As AntviewAx2.Antview Private Sub Form_Initialize()   Dim Err As Boolean   Dim ErrStat As AntviewAx2.TxWebErrorStatus     Set EdgeBrowser = Controls.Add("AntViewAx2.Antview", "EdgeBrowser")   EdgeBrowser.Top = 300   EdgeBrowser.Left = 200   EdgeBrowser.Height = 4000   EdgeBrowser.Width = 10000   EdgeBrowser.EventsUseHexadecimal = True   EdgeBrowser.Visible = True   EdgeBrowser.CreateWebView   EdgeBrowser.UnlockControl "ExampleCompany", "WI5PO2-2KSU3Q-HWFXFU-IUMU2V-QF8P2F"   EdgeBrowser.Navigate "https://www.microsoft.com" ' navigatesync does not work when you create the control like above '  EdgeBrowser.NavigateSync "https://www.microsoft.com", Err, ErrStat End Sub

Please be aware that in the case you installed AntView version 1.1 that the code needs to look a little bit different.

Code:
Public WithEvents EdgeBrowser As AntviewAx.Antview Private Sub Form_Initialize()   Dim Err As Boolean   Dim ErrStat As AntviewAx.TxWebErrorStatus     Set EdgeBrowser = Controls.Add("AntViewAx.Antview", "EdgeBrowser")   EdgeBrowser.Top = 300   EdgeBrowser.Left = 200   EdgeBrowser.Height = 4000   EdgeBrowser.Width = 10000   EdgeBrowser.EventsUseHexadecimal = True   EdgeBrowser.Visible = True   EdgeBrowser.CreateWebView   EdgeBrowser.UnlockControl "ExampleCompany", "WI5PO2-2KSU3Q-HWFXFU-IUMU2V-QF8P2F"   EdgeBrowser.Navigate "https://www.microsoft.com" ' navigatesync does not work when you create the control like above '  EdgeBrowser.NavigateSync "https://www.microsoft.com", Err, ErrStat End Sub

We'll add an example of this to the standard examples just to make sure that it is easier to find on how-to do this.

--
Wil


RE: VB6: How to create an Antview control dynamically? - AlKalm - 2024-11-13

Hello, Wil!

It was a great help for me! By the way, I should figure it out myself... Confused