小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

單文檔添加地圖(VC++6.0)

 蘇梅家家 2009-09-15

給單文檔添加地圖的方法

創(chuàng)建單文檔后,在程序的目錄文件里面考入兩個類的頭文件和源文件:yimaencyimaenchead還有授權(quán)的lib文件。哦,對了,還有例子里面的3個文件夾。

一:CMainFrame頭文件添加public控件對象:

       CYimaEnc m_yimaEncCtrl;

莫要忘記包含頭文件:#include "yimaenc.h"

#include "yimaenchead.h"

 

二:CMainFrame::OnCreate里面創(chuàng)建控件

 

       m_yimaEncCtrl.Create(NULL, NULL, CRect(0, 0, 0, 0), this,

              ID_YIMAENC_CTRL); 

       TCHAR curWorkDir[1024];

       GetCurrentDirectory(1024, curWorkDir);

       if (!m_yimaEncCtrl.Init(curWorkDir)) //YIMAENC COMMENT:  YimaEnc Control interoped!

       {

              AfxMessageBox("Failed to init YimaEnc Control, may be the config files are not exits!");

              return -1;

       }  

       m_yimaEncCtrl.tmOpenMapDataFile("MarineMap\\marineMap.ymc"); //讀入自定義海圖數(shù)據(jù)文件

 

        三:在view類里添加消息響應(yīng):WM_SETFOCUS

并在頭文件里添加       CYimaEnc* m_pYimaEncCtrl;

在新增函數(shù)OnSetFocus里添加下列代碼

       if (m_pYimaEncCtrl == NULL)

       {

              CMainFrame* pFrame = (CMainFrame*)(AfxGetApp()->m_pMainWnd);

             

              if (pFrame != NULL)

              {

                     m_pYimaEncCtrl = &pFrame->m_yimaEncCtrl;

                    

                     RECT clientRect;

                     GetClientRect(&clientRect);

                    

                     // RefreshDrawer 在初始化屏幕 改變海圖屏幕大小時應(yīng)該被調(diào)用

                     m_pYimaEncCtrl->RefreshDrawer((long)m_hWnd,

                            clientRect.right - clientRect.left,

                            clientRect.bottom - clientRect.top,

                            0, 0);

                    

                     bool bTestGetLibMapInfo = false;

                     if (bTestGetLibMapInfo)

                     {

                            float originalScale = 0;

                            long left, right, up, down;

                           

                            m_pYimaEncCtrl->GetLibMapInfo(0, NULL, NULL, &originalScale,

                                   &left, &right, &up, &down, NULL, NULL); //得到海圖庫海圖信息

                           

                            m_pYimaEncCtrl->SetCurrentScale(originalScale);

                           

                            m_pYimaEncCtrl->CenterMap( ((float)left + right) / 2,

                                   ((float)up + down) / 2);                                         

                           

                                   /* YIMAENC COMMENT: 注意!! 由于地理坐標(biāo)值可能接近4字節(jié)

                                   long 型變量的上限(但不會超出),所以在做加法或乘法時需要轉(zhuǎn)換為float

                            以防止溢出!*/                                      

                     }

                    

                     m_pYimaEncCtrl->FocusLibMap(0);

              }

       }

}

 

 

動態(tài)添加新函數(shù)RefreshScreenMap

并添加代碼

void CText1View::RefreshScreenMap()

{

       if (m_pYimaEncCtrl != NULL)

       { 

              HDC hdc = ::GetDC(m_hWnd);

              m_pYimaEncCtrl->DrawMapsInScreen((long)hdc);

              ::ReleaseDC(m_hWnd, hdc);

       }

}

 

四:添加WM_SIZE
并添加代碼

       if (m_pYimaEncCtrl != NULL)

       {

              RECT clientRect;

              GetClientRect(&clientRect);

             

              // RefreshDrawer 在初始化屏幕 改變海圖屏幕大小時應(yīng)該被調(diào)用

              m_pYimaEncCtrl->RefreshDrawer((long)m_hWnd,

                     clientRect.right - clientRect.left,

                     clientRect.bottom - clientRect.top,

                     0, 0); 

             

              CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;

             

動態(tài)添加函數(shù)RefreshScaleStatusBar

       /***************** 刷新比例尺信息顯示欄 ********************/

void CTextView::RefreshScaleStatusBar()

{

       CStatusBar * pStatusBar = (CStatusBar *)AfxGetApp()->m_pMainWnd->

              GetDescendantWindow(AFX_IDW_STATUS_BAR);

      

       if (pStatusBar!=NULL)

       {

              float curScale = m_pYimaEncCtrl->GetCurrentScale();

             

              CString strCurScale;                   

              strCurScale.Format("比例尺 1 : %d", (int)curScale);

              pStatusBar->SetPaneText(INDEX_PANE_FOR_SCALE, strCurScale);

       }

}

 

 

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多