找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 849|回复: 0

[求助] 怎么在64位的cad2014里实现common dialog的功能

[复制链接]
发表于 2016-7-29 11:20:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
cad2014里不能引用原来vb6.0的common dialog的控件,我在网上,也查了用api的方法调用comdlg32.dll的方法,但是都不起作用,请各位大神帮忙看一下怎么解决!
  1. Public Declare PtrSafe Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOPENFILENAME As OPENFILENAME) As Long
  2. Public Declare PtrSafe Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" (pOPENFILENAME As OPENFILENAME) As Long


  3. Type OPENFILENAME
  4.     lStructSize As Long
  5.     hwndOwner As Long
  6.     hInstance As Long
  7.     lpstrFilter As String
  8.     lpstrCustomFilter As String
  9.     nMaxCustFilter As Long
  10.     nFilterIndex As Long
  11.     lpstrFile As String
  12.     nMaxFile As Long
  13.     lpstrFileTitle As String
  14.     nMaxFileTitle As Long
  15.     lpstrInitialDir As String
  16.     lpstrTitle As String
  17.     flags As Long
  18.     nFileOffset As Integer
  19.     nFileExtension As Integer
  20.     lpstrDefExt As String
  21.     lCustData As Long
  22.     lpfnHook As Long
  23.     lpTemplateName As String
  24. End Type
  25. Public Const OFN_OVERWRITEPROMPT = &H2
  26. Public Const OFN_HIDEREADONLY = &H4
  27. Public Const OFN_PATHMUSTEXIST = &H800
  28. Public Const OFN_FILEMUSTEXIST = &H1000

  29. Public Function GetDialog(ByVal sMethod As String, ByVal sTitle As String, ByVal FileType As String, ByVal sFileName As String) As String
  30. 'Public Function GetDialog(ByVal sMethod As String, ByVal sTitle As String, ByVal sFileName As String) As String
  31.     Err.Clear
  32.     On Error GoTo myError
  33.     Dim rtn As Long, Pos As Integer
  34.     Dim file As OPENFILENAME
  35.     'file.lStructSize = Len(file)
  36.     'file.hInstance = ThisDrawing.Application.HWND32
  37.     file.hInstance = ThisDrawing.HWND32
  38.     file.lpstrFile = sFileName & VBA.String$(255 - VBA.Len(sFileName), 0)
  39.     file.nMaxFile = 255
  40.     file.lpstrFileTitle = VBA.String$(255, 0)
  41.     file.nMaxFileTitle = 255
  42.     file.lpstrInitialDir = ""
  43.     'file.lpstrFilter = "Excel文件" & vbNullChar & "*.xls"  '这个为xls文件
  44.     file.lpstrFilter = FileType & vbNullChar & FileType  '这个为xls文件"
  45.     file.lpstrTitle = sTitle
  46.     file.lStructSize = Len(file)
  47.     If VBA.UCase(sMethod) = "OPEN" Then
  48.         file.flags = OFN_HIDEREADONLY + OFN_PATHMUSTEXIST + OFN_FILEMUSTEXIST
  49.         rtn = GetOpenFileName(file)
  50.     Else
  51.         file.lpstrDefExt = "exe"
  52.         file.flags = OFN_HIDEREADONLY + OFN_PATHMUSTEXIST + OFN_OVERWRITEPROMPT
  53.         rtn = GetSaveFileName(file)
  54.     End If
  55.     If rtn > 0 Then
  56.         Pos = InStr(file.lpstrFile, VBA.Chr$(0))
  57.         If Pos > 0 Then
  58.             GetDialog = VBA.Left$(file.lpstrFile, Pos - 1)
  59.         End If
  60.     End If
  61.     Exit Function
  62. myError:
  63.     'Err.Raise
  64.     GetDialog = "FileName Error!"
  65. End Function
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-23 20:49 , Processed in 0.179964 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表