Select to view content in your preferred language

LoadMxFile not loading

387
0
06-09-2010 02:39 PM
KevinFournier
Emerging Contributor
I have a method wrapping the Map Control's LoadMxFile method. It returns OK but no map loads. Any ideas why this might happen? I'm working in C++/MFC:

BSTR CBGMapCtrl::LoadMxFile(LPCTSTR lpszPath, LPCTSTR lpszName, LPCTSTR lpszPassword)
{
 CString strResult;

 if( m_pMapControl )
 {
  COleVariant varName(vtMissing), varPassword(vtMissing);

  if( lpszName && *lpszName )
   varName = COleVariant( lpszName );
  if( lpszPassword && *lpszPassword )
   varPassword = COleVariant( lpszPassword );

  CComBSTR strPath( lpszPath );
  VARIANT_BOOL bOk = FALSE;
  if( SUCCEEDED(m_pMapControl->CheckMxFile(strPath, &bOk)) && bOk )
  {
   HRESULT hr = m_pMapControl->LoadMxFile( CComBSTR(lpszPath), varName, varPassword );
   if( SUCCEEDED(hr) )
    strResult = _T("1");
   else
   {
    switch( hr )
    {
     case 0x800a03fa: strResult = _T("The specified filename is invalid, the contents are corrupt or invalid."); break;
     case 0x800a03fb: strResult = _T("The specified filename cannot be found."); break;
     case 0x800a03fc: strResult = _T("The specified filename is invalid, the file cannot be opened."); break;
     case 0x800a03fd: strResult = _T("The specified document has timed out."); break;
     case 0x800a0400: strResult = _T("The specified map or index parameter is not a valid type."); break;
     case 0x800a0407: strResult = _T("Password required to read this map document."); break;
     case 0x800a0408: strResult = _T("The specified password is incorrect."); break;
     case 0x800a0409: strResult = _T("The password parameter does not contain a valid string."); break;
     case 0x800a0413: strResult = _T("The version of the specified document cannot be read by this software."); break;
     case 0x800a0414: strResult = _T("The specified document can only be opened in the ArcReader application."); break;
     case 0x800a0415: strResult = _T("The specified document does not allow access to internal objects."); break;
     case 0x800a0429: strResult = _T("The specified Published Map File contains a Globe and cannot be open."); break;
     default: strResult.Format( _T("0x%x"), hr );
    }
   }
  }
  else
   strResult = _T("Invalid MXD file.");
 }
 else
  strResult = _T("Map control has not been initialized.");

 return strResult.AllocSysString();
}
0 Kudos
0 Replies