代码名称:Total教学之结合Delphi让Mapbasic无所不能之二(一次性打开多个文件)


源码下载: 下载地址1

下载要求:论坛注册用户

作者/收集者:liuhui_sky from total

开发环境:MapBasic + Delphi + Professional

代码介绍:

Include "mapbasic.def"
Include "menu.def"
Include "icons.def"
'声明部分
Declare Sub Main
Declare Sub ShowHideInspector
Declare Sub RemoteMsgHandler
Declare Sub Exit
Declare Function GetFocus Lib "User32"() as Integer
Declare Function ShowDialog Lib "Export_TEMS_Cells_Files" () as Logical
Declare Function CreateManagerDialog Lib "Export_TEMS_Cells_Files" (ByVal Handle as Integer) as Logical
Declare Function Map2Del Lib "Export_TEMS_Cells_Files" (Str as String) as Logical
Dim nWin as integer


Sub Main
  Dim Handle, Start as Integer
  Dim Result1, Result2, Flag1 as Logical
  Dim str as string
  
  nWin = FrontWindow()
  '建立菜单
  Create Menu "DialogManager" As 
    "Exit" Calling exit
    
  Alter Menu Bar Add "DialogManager"
 
  Handle = GetFocus()'获得Mapinfo窗口的句柄
  Result1 = CreateManagerDialog(Handle)'建立对话框
  Result2 = ShowDialog()'显示对话框
  
  'tell the dll where its placed on the drive
  str = "#S#" + ApplicationDirectory$() '传递路径
  Flag1 = Map2Del(str)'传递成功则为TRUE

End Sub
Sub RemoteMsgHandler  '这个就不用解释了吧,不懂看Mapbasic帮助
 Dim szDelphi as string
 Dim str  as string
 Dim bGo as logical
 Dim HeadMsg as String
 
 szDelphi = CommandInfo(CMD_INFO_MSG)
 HeadMsg=Left$(szDelphi,1)
      If HeadMsg="#" then
      Print Right$(szDelphi,Len(szDelphi)-1)
      Else
        
      End if
  
End Sub

Sub Exit
 
 DDETerminateAll

 End Program
end sub

这样解释挺累的,还是自己看原代码吧:-)