HOW TO
This document steps through the procedures and code required to add and initialize the legend control (MO2Legend.ocx) in a Visual C++ project.
Warning:
If you are not using the MapHelper files, skip to Step 6.
Code:
#include "MapHelper.h"
Code:
LPDISPATCH pDisp =::GetIDispatch(m_map);
m_legend.setMapSource(&pDisp);
pDisp->Release();
Warning:
Skip to Step 7.
Code:
LPDISPATCH pDisp = 0;
LPUNKNOWN pUnknown = m_map.GetControlUnknown();
if (pUnknown)
pUnknown->QueryInterface(IID_IDispatch, (void**)&pDisp);
m_legend.setMapSource(&pDisp);
pDisp->Release();
Code:
//set font properties:
short idx = 0;
m_legend.SetActive(&idx, TRUE);
COleFont fnt(m_legend.GetFont());
fnt.SetName(_T("Times"));
m_legend.SetRefFont(fnt);
m_legend.SetBackColor(moOrange);
Code:
BOOL bLoad = TRUE;
m_legend.LoadLegend(&bLoad);
Get help from ArcGIS experts
Download the Esri Support App