# Tiles/TileProviders in my MFC Application

**URL:** <https://mapwindow.discourse.group/t/tiles-tileproviders-in-my-mfc-application/399>\
**Category:** MapWinGIS\
**Created:** [December 23, 2019, 9:45pm UTC](https://mapwindow.discourse.group/t/tiles-tileproviders-in-my-mfc-application/399 "2019-12-23T21:45:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KehindeIsijola](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@KehindeIsijola](https://mapwindow.discourse.group/u/KehindeIsijola)\
**Post date:** [December 23, 2019, 9:45pm UTC](https://mapwindow.discourse.group/t/tiles-tileproviders-in-my-mfc-application/399/1 "2019-12-23T21:45:47Z")

</div>

I have issues with my code below: The problem occurs at the point of assignment:  
_\_tiles = m\_map.get\_Tiles();_  
Can anybody assist me to know what may be wrong?

```
#pragma region PopulateProvidersCombo
	ITilesPtr _tiles;
	_tiles.CreateInstance(__uuidof(Tiles));
	_tiles = m_map.get_Tiles();
	ITileProvidersPtr _TileProviders;
	_TileProviders.CreateInstance(__uuidof(TileProviders));
	_TileProviders = _tiles->Providers;
	CMFCRibbonComboBox* pComboBox = DYNAMIC_DOWNCAST(CMFCRibbonComboBox, m_pWnd->m_wndRibbonBar.FindByID(ID_TOOLS_TILEPROVIDER));
	pComboBox->RemoveAllItems();
	for (int i = 0; i < _TileProviders->Count; i++)
	{
		pComboBox->AddItem((_bstr_t)_TileProviders->GetName(i));
	}
#pragma endregion

```

I have not seen any post that addressed the issue. Any assistance is appreciated.  
Thank you.

---

<div class="post-metadata">

**Author:** ![KehindeIsijola](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@KehindeIsijola](https://mapwindow.discourse.group/u/KehindeIsijola)\
**Post date:** [January 7, 2020, 2:28pm UTC](https://mapwindow.discourse.group/t/tiles-tileproviders-in-my-mfc-application/399/2 "2020-01-07T14:28:44Z")

</div>

I have solution to this question as follows:  
#pragma region PopulateProvidersCombo

```
	LPDISPATCH m_tiles = m_map.get_Tiles();
    struct ITiles* _tiles = nullptr;
    m_tiles->QueryInterface(IID_ITiles, (void**)&_tiles);

	ITileProvidersPtr m_TileProviders;
	m_TileProviders.CreateInstance(__uuidof(TileProviders));
	m_TileProviders = _tiles->Providers;
	CMFCRibbonComboBox* pComboBox = DYNAMIC_DOWNCAST(CMFCRibbonComboBox, m_pWnd->m_wndRibbonBar.FindByID(ID_TOOLS_TILEPROVIDER));
	pComboBox->RemoveAllItems();
    // add ProviderNone
    // and then the legacy providers
	for (int i = 0; i < m_TileProviders->Count; i++)
	{
		pComboBox->AddItem((_bstr_t)m_TileProviders->GetName(i));
	}
	m_tiles->Release();
    // lastly add CustomProvider
 // pComboBox->SelectItem(
   
#pragma endregion

```

I will appreciate a better approach.  
Note: my application uses CMFCRibbonBar UI.

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [February 19, 2020, 6:28am UTC](https://mapwindow.discourse.group/t/tiles-tileproviders-in-my-mfc-application/399/3 "2020-02-19T06:28:47Z")

</div>

Closed on February 19, 2020, 6:28am UTC

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.
