//mapx打开tab保存tab文件:
static char BASED_CODE szTabFilter[] = "MapInfo Map Files (*.tab)|*.tab|All Files (*.*)|*.*||"; // display a file open dialog to get 1 or more filenames 
// then open the mapinfo .tab files one at a time 
void CGleditView::OnFileOpen()  

CFileDialog dlgFile(TRUE, "*.tab", NULL, 0, szTabFilter, this); 
dlgFile.m_ofn.lpstrTitle = "Open MapInfo Tables"; // We want a multiple select file open, but on NT 3.51 the GetNextPathName() call 
// returns bogus filenames (Can´t handle spaces I think.) 
// So if NT 3.51 or less, then don´t set the multi-select flag 
OSVERSIONINFO vers; 
vers.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 
if (GetVersionEx(&vers)) { 
if (vers.dwMajorVersion < 4 && vers.dwPlatformId == VER_PLATFORM_WIN32_NT) { 
// no multiple select 

else { 
dlgFile.m_ofn.Flags |= OFN_ALLOWMULTISELECT; 

} if (dlgFile.DoModal() == IDCANCEL) 
return; try { 
POSITION pos = dlgFile.GetStartPosition(); 
CString strFile; 
while (pos) { 
strFile = dlgFile.GetNextPathName(pos); 
m_ctrlMapX.GetLayers().Add(strFile); 


catch (COleDispatchException *e) { 
e->ReportError(); 
e->Delete(); 

catch (COleException *e) { 
e->ReportError(); 
e->Delete(); 
} } 
void CGleditView::OnFileSave()  

CFileDialog dlgFile(false, "*.tab", NULL, 0, szTabFilter, this); 
dlgFile.m_ofn.lpstrTitle = "保存图层文件"; // We want a multiple select file open, but on NT 3.51 the GetNextPathName() call 
// returns bogus filenames (Can&acute;t handle spaces I think.) 
// So if NT 3.51 or less, then don&acute;t set the multi-select flag 
OSVERSIONINFO vers; 
vers.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 
if (GetVersionEx(&vers)) { 
if (vers.dwMajorVersion < 4 && vers.dwPlatformId == VER_PLATFORM_WIN32_NT) { 
// no multiple select 

else { 
dlgFile.m_ofn.Flags |= OFN_ALLOWMULTISELECT; 

} if (dlgFile.DoModal() == IDCANCEL) 
return; try { 
CString strFile, FileName; 
strFile = dlgFile.GetPathName(); 
FileName = dlgFile.GetFileName(); 
//m_ctrlMapX.SetGeoSet(FileName); } 
catch (COleDispatchException *e) { 
e->ReportError(); 
e->Delete(); 

catch (COleException *e) { 
e->ReportError(); 
e->Delete(); 
} } 

解决方案 »

  1.   

    这其中有MFC框架的内容
    但VB中没有与MFC框架对应的东西,
    所以,
    只是翻译过去,也不能用.
      

  2.   

    我会点vb,但不会vc啊,我想实现的功能别人用vc写的,我的目的是想用vb实现同样的功能,我的难点是在保存tab文件的功能上,不知道那位高手能帮我这个忙,同时谢谢大家!!
      

  3.   

    Dim str As String
    Private Sub Command1_Click()CommonDialog1.Filter = "*.tab"
    CommonDialog1.ShowOpenIf CommonDialog1.CancelError = True Then
    End Ifstr = CommonDialog1.FileName
    MsgBox str
    End SubPrivate Sub Command2_Click()CommonDialog1.Filter = "*.tab"
    CommonDialog1.ShowSave
    //这里str为文件路径,把它的内容读到新文件中就行啊
    If CommonDialog1.CancelError = True Then
        MsgBox "ok"
    End IfEnd Sub
      

  4.   

    dim szTabFilter as string
    szTabFilter = MapInfo Map Files (*.tab)|*.tab|All Files (*.*)|*.*||"添加一个CommonDlgCtrl6.0, 名称dlg
    private sub FileOpen()
    {
        Dlg.Filter = szTabFilter
        Dlg.Flags = FileOpenConstants.cdlOFNFileMustExist
        Dlg.ShowOpen