Thanks so much Kirk, this appears to be the good way.
My problem was to generate the Axtoolbar and AxmapControl programmatically, otherwise, the application don't start at all as the license is required to initalize manually drawed components.
I tried then to build the code, but my controls doesn't appear on the tabpage. I tried to insert the drawing of a combo, which worked. All the code run correctly with no error message, but no map, no toolbar at the end.
My mistake was to initialize components inside Form Load and not inside New. I let the code if it can help.
Thanks very much again Kirk !
Friend WithEvents AxToolbarControl1 As ESRI.ArcGIS.Controls.AxToolbarControl = New ESRI.ArcGIS.Controls.AxToolbarControl
Friend WithEvents AxLicenseControl1 As ESRI.ArcGIS.Controls.AxLicenseControl = New ESRI.ArcGIS.Controls.AxLicenseControl
Friend WithEvents AxMapControl1 As ESRI.ArcGIS.Controls.AxMapControl = New ESRI.ArcGIS.Controls.AxMapControl
Private Function CheckOutLicenses(ByVal productCode As esriLicenseProductCode) As esriLicenseStatus
Dim m_pAoInitialize As AoInitialize = New AoInitialize
m_pAoInitialize.Initialize(productcode)
Return m_pAoInitialize.IsProductCodeAvailable(ProductCode)
End Function
Main code ->
If CheckOutLicenses(esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB) = esriLicenseStatus.esriLicenseAvailable Then
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Tablet))
CType(AxToolbarControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(AxLicenseControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(AxMapControl1, System.ComponentModel.ISupportInitialize).BeginInit()
'
'TabCarte
'
TabCarte.Controls.Add(AxToolbarControl1)
TabCarte.Controls.Add(AxLicenseControl1)
TabCarte.Controls.Add(AxMapControl1)
AxToolbarControl1.Visible = True
AxMapControl1.Visible = True
AxMapControl1.BringToFront()
AxToolbarControl1.BringToFront()
'TabCarte.Location = New System.Drawing.Point(4, 22)
'TabCarte.Name = "TabCarte"
'TabCarte.Padding = New System.Windows.Forms.Padding(3)
'TabCarte.Size = New System.Drawing.Size(1001, 707)
'TabCarte.TabIndex = 2
'TabCarte.Text = "Carte"
'TabCarte.UseVisualStyleBackColor = True
'
'AxToolbarControl1
'
AxToolbarControl1.Location = New System.Drawing.Point(6, 6)
AxToolbarControl1.Name = "AxToolbarControl1"
AxToolbarControl1.OcxState = CType(resources.GetObject("AxToolbarControl1.OcxState"), System.Windows.Forms.AxHost.State)
AxToolbarControl1.Size = New System.Drawing.Size(984, 28)
AxToolbarControl1.TabIndex = 2
'
'AxLicenseControl1
'
AxLicenseControl1.Enabled = True
AxLicenseControl1.Location = New System.Drawing.Point(24, 0)
AxLicenseControl1.Name = "AxLicenseControl1"
AxLicenseControl1.OcxState = CType(resources.GetObject("AxLicenseControl1.OcxState"), System.Windows.Forms.AxHost.State)
AxLicenseControl1.Size = New System.Drawing.Size(32, 32)
AxLicenseControl1.TabIndex = 1
'
'AxMapControl1
'
AxMapControl1.Location = New System.Drawing.Point(0, 40)
AxMapControl1.Name = "AxMapControl1"
AxMapControl1.OcxState = CType(resources.GetObject("AxMapControl1.OcxState"), System.Windows.Forms.AxHost.State)
AxMapControl1.Size = New System.Drawing.Size(990, 656)
AxMapControl1.TabIndex = 0
'
CType(AxToolbarControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(AxLicenseControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(AxMapControl1, System.ComponentModel.ISupportInitialize).EndInit()
ArcToolbar_Init()
Data_Load()
End If
Sub ArcToolbar_Init()
AxToolbarControl1.SetBuddyControl(AxMapControl1.Object)
'Add control command items to the ToolbarControl
AxToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", -1, -1, True, 0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsMapPanTool", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
AxToolbarControl1.AddItem("esriControls.ControlsMapZoomToLastExtentBackCommand", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconOnly)
'Add extension command items to the ToolbarControl
AxToolbarControl1.AddItem("ZoomFactorExtensionVBNet.SetZoomFactor", -1, -1, True, 0, esriCommandStyles.esriCommandStyleIconAndText)
AxToolbarControl1.AddItem("ZoomFactorExtensionVBNet.ZoomIn", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconAndText)
AxToolbarControl1.AddItem("ZoomFactorExtensionVBNet.ZoomOut", -1, -1, False, 0, esriCommandStyles.esriCommandStyleIconAndText)
'Get the extension manager admin
m_pExtensionManagerAdmin = New ExtensionManagerClass
''Add the extension to the extension manager
Dim pUID As New UIDClass
pUID.Value = "ZoomFactorExtensionVBNet.ZoomExtension"
Call m_pExtensionManagerAdmin.AddExtension(pUID, 0)
'Get the extension manager
Dim pExtensionManager As IExtensionManager
'Dim m_pExtensionManagerAdmin As IExtensionManagerAdmin
pExtensionManager = CType(m_pExtensionManagerAdmin, IExtensionManager)
'Get the extension from the extension manager
Dim pExtensionConfig As IExtensionConfig
pExtensionConfig = CType(pExtensionManager.FindExtension("Zoom Factor Extension"), IExtensionConfig)
'Set the enabled state
pExtensionConfig.State = esriExtensionState.esriESEnabled
End Sub
Private Sub Data_Load()
Dim sFilePath As String
sFilePath = "D:\test\datas.mxd"
If sFilePath = "" Then Exit Sub
'Validate and load map document
If AxMapControl1.CheckMxFile(sFilePath) Then
AxMapControl1.LoadMxFile(sFilePath)
'Enabled MapControl
AxMapControl1.Enabled = True
Else
MsgBox(sFilePath & " is not a valid ArcMap document")
Exit Sub
End If
End Sub