求助~~为什么还是“建立空文档失败”?

phl61894589 2009-07-13 07:22:52
我在VC下装了mapx控件,刚刚在网上下的地图导航“MapNavigate”的源码,可为什么一运行就提示 建立空文档失败 呢?试了N久都没什么进展,恳请高手帮忙啊~~万分感激~~ 附网上下载的navigate源码及地图~~跪求帮助!
// MapNavigateView.cpp : implementation of the CMapNavigateView class
//

#include "stdafx.h"
#include "MapNavigate.h"

#include "MapNavigateDoc.h"
#include "MapNavigateView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMapNavigateView

IMPLEMENT_DYNCREATE(CMapNavigateView, CView)

BEGIN_MESSAGE_MAP(CMapNavigateView, CView)
//{{AFX_MSG_MAP(CMapNavigateView)
ON_WM_CREATE()
ON_WM_SIZE()
ON_COMMAND(ID_BUTTON32774, OnButton32774)
ON_COMMAND(ID_BUTTON32775, OnButton32775)
ON_COMMAND(ID_BUTTON32776, OnButton32776)
ON_COMMAND(ID_BUTTON32777, OnButton32777)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

BEGIN_EVENTSINK_MAP(CMapNavigateView, CView)
ON_EVENT(CMapNavigateView, IDC_MAP, 6 /* MapViewChanged */, OnMapViewChangedMap, VTS_NONE)
END_EVENTSINK_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMapNavigateView construction/destruction

CMapNavigateView::CMapNavigateView()
{
// TODO: add construction code here
pEyeDlg = NULL;
m_Created = 0;
}

CMapNavigateView::~CMapNavigateView()
{
if(pEyeDlg!=NULL)
{
delete pEyeDlg;
}
}

BOOL CMapNavigateView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMapNavigateView drawing

void CMapNavigateView::OnDraw(CDC* pDC)
{
CMapNavigateDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CMapNavigateView printing

BOOL CMapNavigateView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}

void CMapNavigateView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}

void CMapNavigateView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMapNavigateView diagnostics

#ifdef _DEBUG
void CMapNavigateView::AssertValid() const
{
CView::AssertValid();
}

void CMapNavigateView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}

CMapNavigateDoc* CMapNavigateView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMapNavigateDoc)));
return (CMapNavigateDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMapNavigateView message handlers

int CMapNavigateView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;

// TODO: Add your specialized creation code here
CRect rec;
GetClientRect(rec);
m_ctrlMapX.SetGeoSet("map\\西安.gst");
if(m_map.Create(NULL,WS_VISIBLE,rec,this,IDC_MAP))
{

m_Created = 1;
}
else
return -1;
return 0;
}

void CMapNavigateView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
m_map.MoveWindow(0,0,cx,cy);
// TODO: Add your message handler code here

}

void CMapNavigateView::OnButton32774()
{
// TODO: Add your command handler code here
if(pEyeDlg==NULL)
{
pEyeDlg = new CEyeMap(this);
}
CString str[6];
str[0] = m_tempclientpath+"\\map\\城墙.tab";
str[1] = m_tempclientpath+"\\map\\铁路.tab";
str[2] = m_tempclientpath+"\\map\\主要街道.tab";
str[3] = m_tempclientpath+"\\map\\次要街道.tab";
str[4] = "-1";
pEyeDlg->strMap = str;
pEyeDlg->InitMap(&m_map);
pEyeDlg->m_backcolor = RGB(0,0,0);
if(pEyeDlg->GetSafeHwnd()==0)
{
BOOL a = pEyeDlg->Create();
}
else
{
return;
}
CRect rec1;
pEyeDlg->GetWindowRect(rec1);
CRect rec;
this->GetWindowRect(rec);
pEyeDlg->SetWindowPos(&wndTop,rec.right-rec1.right+rec1.left,rec.bottom-rec1.bottom+rec1.top,rec1.right-rec1.left,rec1.bottom-rec1.top,SWP_SHOWWINDOW);
pEyeDlg->ShowWindow(SW_SHOWNORMAL);
}


void CMapNavigateView::OnMapViewChangedMap()
{
if(m_Created==1)

{
CWnd* pWnd = (CWnd*)pEyeDlg;
if(pWnd->GetSafeHwnd()!=0)
{
pWnd->PostMessage(WM_MAPCHANGING,0,0);
}
}
}

void CMapNavigateView::OnButton32775()
{
// TODO: Add your command handler code here
m_map.SetCurrentTool(1003);
}

void CMapNavigateView::OnButton32776()
{
// TODO: Add your command handler code here
m_map.SetCurrentTool(1004);
}

void CMapNavigateView::OnButton32777()
{
// TODO: Add your command handler code here
m_map.SetCurrentTool(1001);
}
...全文
131 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
togoblime 2009-07-13
  • 打赏
  • 举报
回复
调试一下看是不是OnCreate中的m_map.Create(NULL,WS_VISIBLE,rec,this,IDC_MAP)失败了,导致返回了-1
  • 打赏
  • 举报
回复
查看一下你的IDR_MAINFRAME资源是否正确 工具条是否创建成功

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧