I am creating a 16 bit DLL using PB/DLL 2.0. This DLL will be
called from VB 3.0 16 bit. I am receiving an error message when
trying to compile the DLL for testing. I can compile the DLL for
use with VB 3.0 and access the DLL and display the File Open Dialog.
There is a bug that preventing diplay of files. I took most of this
code from someones previous form post about a 32 bit File Open. I
need to be able to debug this code to resolve the issue.
Thanks for any help or suggestions.
Spencer
The following is the code:
PowerBasic Code
%DEBUG = 1 'set to 0 for no debugging
$IF %DEBUG
$DEBUG PBD ON
$COMPILE DLL
$INCLUDE "\pbdll60\winapi\WINAPI.INC"
$INCLUDE "\PBDLL60\WINAPI\COMMDLG.INC"
$INCLUDE "\PBDLL60\WINAPI\CTL3D.INC"
DECLARE FUNCTION OpenFilesDialog(BYVAL hWnd AS LONG, _ ' parent window
Caption AS ASCIIZ, _ ' caption
Filespec AS ASCIIZ, _ ' filename (input/output)
InitialDir AS ASCIIZ, _ ' start directory
Filter AS ASCIIZ, _ ' filename filter
DefExtension AS ASCIIZ, _ ' default extension
Flags AS LONG) AS LONG ' flags
SUB PBDebug () EXPORT
OPTION EXPLICIT
Dim returnvalue as long
Dim sCaption as String
DIM sFileName AS String
DIM sPath AS String
Dim sFilter as String
Dim sDefExt as String
DIM lStyle AS LONG
sCaption = "File Open Dialog Test"
sFileName = "*.*"
sPath = CURDIR$
sFilter = "All Files (*.*)|*.*|Text files (*.TXT, *.BAT)|*.TXT;*.BAT|"
sDefExt = "*.txt"
lStyle = %OFN_ALLOWMULTISELECT Or %OFN_FILEMUSTEXIST
returnvalue = OpenFilesDialog(0, sCaption, sFileName, sPath, sFilter, sDefExt, lStyle)
END SUB
$ELSE
$COMPILE DLL
$INCLUDE "\pbdll60\winapi\WINAPI.INC"
$INCLUDE "\PBDLL60\WINAPI\COMMDLG.INC"
$INCLUDE "\PBDLL60\WINAPI\CTL3D.INC"
DECLARE FUNCTION OpenFilesDialog(BYVAL hWnd AS LONG, _ ' parent window
Caption AS ASCIIZ, _ ' caption
Filespec AS ASCIIZ, _ ' filename (input/output)
InitialDir AS ASCIIZ, _ ' start directory
Filter AS ASCIIZ, _ ' filename filter
DefExtension AS ASCIIZ, _ ' default extension
Flags AS LONG) AS LONG ' flags
$ENDIF
'----------------------------------------------------------
'- OpenFilesDialog
'----------------------------------------------------------
Function OpenFilesDialog( BYVAL hWnd AS LONG, _ ' parent window
Caption AS ASCIIZ, _ ' caption
Filespec AS ASCIIZ, _ ' filename (input/output)
InitialDir AS ASCIIZ, _ ' start directory
Filter AS ASCIIZ, _ ' filename filter
DefExtension AS ASCIIZ, _ ' default extension
Flags AS LONG) EXPORT AS LONG ' flags
LOCAL sFile AS STRING
LOCAL Ofn AS OPENFILENAME
LOCAL zFileTitle AS ASCIIZ * 256
LOCAL zFilter AS ASCIIZ * 256
LOCAL zInitialDir AS ASCIIZ * 256
LOCAL zTitle AS ASCIIZ * 256
LOCAL zDefExt AS ASCIIZ * 10
REPLACE "|" WITH CHR$(0) IN Filter
IF LEN(InitialDir) = 0 THEN
InitialDir = CURDIR$
END IF
zFilter = Filter + CHR$(0)
zInitialDir = InitialDir + CHR$(0)
sFile = STRING$(4096,0) 'PLENTY OF ROOM FOR MULTIPLE FILES
MID$(sFile,1) = FileSpec
zDefExt = DefExtension + CHR$(0)
zTitle = Caption + CHR$(0)
ofn.lStructSize = SIZEOF(ofn)
ofn.hWndOwner = hWnd
ofn.lpstrFilter = VARPTR(zFilter)
ofn.nFilterIndex = 1
ofn.lpstrFile = STRPTR(sFile)
ofn.nMaxFile = LEN(sFile)
ofn.lpstrFileTitle = VARPTR(zFileTitle)
ofn.nMaxFileTitle = SIZEOF(zFileTitle)
ofn.lpstrInitialDir = VARPTR(zInitialDir)
IF LEN(zTitle) THEN
ofn.lpstrTitle = VARPTR(zTitle)
END IF
ofn.Flags = Flags
ofn.lpstrDefExt = VARPTR(zDefExt)
FUNCTION = GetOpenFilename(ofn)
Filespec = RTRIM$(sFile,CHR$(0))
Flags = ofn.Flags
END FUNCTION
Visual Basic 3.0 Code
Declare Function OpenFilesDialog Lib "jds.DLL" Alias "OpenFilesDialog" (ByVal hWnd As
Long, ByVal Caption As String, ByVal Filespec As String, ByVal InitialDir As String, ByVal
Filter As String, ByVal DefExtension As String, Flags As Long) As Long
'File Open/Save Dialog Flags
Global Const OFN_READONLY = &H1&
Global Const OFN_OVERWRITEPROMPT = &H2&
Global Const OFN_HIDEREADONLY = &H4&
Global Const OFN_NOCHANGEDIR = &H8&
Global Const OFN_SHOWHELP = &H10&
Global Const OFN_NOVALIDATE = &H100&
Global Const OFN_ALLOWMULTISELECT = &H200&
Global Const OFN_EXTENSIONDIFFERENT = &H400&
Global Const OFN_PATHMUSTEXIST = &H800&
Global Const OFN_FILEMUSTEXIST = &H1000&
Global Const OFN_CREATEPROMPT = &H2000&
Global Const OFN_SHAREAWARE = &H4000&
Global Const OFN_NOREADONLYRETURN = &H8000&
Dim sCaption As String
Dim sFileName As String
Dim sPath As String
Dim sFilter As String
Dim sDefExt As String
Dim lStyle As Long
sCaption = "File Open Test..."
sFileName = Space$(4096)
sFileName = "*.*"
sPath = CurDir$
sFilter = "All Files (*.*)|*.*|Text files (*.TXT, *.BAT)|*.TXT;*.BAT|"
sDefExt = "*.txt"
lStyle = OFN_ALLOWMULTISELECT Or OFN_FILEMUSTEXIST
If OpenFilesDialog(Me.hWnd, sCaption, sFileName, sPath, sFilter, sDefExt, lStyle) Then
'Need to format sFileName
MsgBox "Directory = " & sFileName
Else
MsgBox "No file(s) selected.", MB_OK, "Error"
End If
called from VB 3.0 16 bit. I am receiving an error message when
trying to compile the DLL for testing. I can compile the DLL for
use with VB 3.0 and access the DLL and display the File Open Dialog.
There is a bug that preventing diplay of files. I took most of this
code from someones previous form post about a 32 bit File Open. I
need to be able to debug this code to resolve the issue.
Thanks for any help or suggestions.
Spencer
The following is the code:
PowerBasic Code
%DEBUG = 1 'set to 0 for no debugging
$IF %DEBUG
$DEBUG PBD ON
$COMPILE DLL
$INCLUDE "\pbdll60\winapi\WINAPI.INC"
$INCLUDE "\PBDLL60\WINAPI\COMMDLG.INC"
$INCLUDE "\PBDLL60\WINAPI\CTL3D.INC"
DECLARE FUNCTION OpenFilesDialog(BYVAL hWnd AS LONG, _ ' parent window
Caption AS ASCIIZ, _ ' caption
Filespec AS ASCIIZ, _ ' filename (input/output)
InitialDir AS ASCIIZ, _ ' start directory
Filter AS ASCIIZ, _ ' filename filter
DefExtension AS ASCIIZ, _ ' default extension
Flags AS LONG) AS LONG ' flags
SUB PBDebug () EXPORT
OPTION EXPLICIT
Dim returnvalue as long
Dim sCaption as String
DIM sFileName AS String
DIM sPath AS String
Dim sFilter as String
Dim sDefExt as String
DIM lStyle AS LONG
sCaption = "File Open Dialog Test"
sFileName = "*.*"
sPath = CURDIR$
sFilter = "All Files (*.*)|*.*|Text files (*.TXT, *.BAT)|*.TXT;*.BAT|"
sDefExt = "*.txt"
lStyle = %OFN_ALLOWMULTISELECT Or %OFN_FILEMUSTEXIST
returnvalue = OpenFilesDialog(0, sCaption, sFileName, sPath, sFilter, sDefExt, lStyle)
END SUB
$ELSE
$COMPILE DLL
$INCLUDE "\pbdll60\winapi\WINAPI.INC"
$INCLUDE "\PBDLL60\WINAPI\COMMDLG.INC"
$INCLUDE "\PBDLL60\WINAPI\CTL3D.INC"
DECLARE FUNCTION OpenFilesDialog(BYVAL hWnd AS LONG, _ ' parent window
Caption AS ASCIIZ, _ ' caption
Filespec AS ASCIIZ, _ ' filename (input/output)
InitialDir AS ASCIIZ, _ ' start directory
Filter AS ASCIIZ, _ ' filename filter
DefExtension AS ASCIIZ, _ ' default extension
Flags AS LONG) AS LONG ' flags
$ENDIF
'----------------------------------------------------------
'- OpenFilesDialog
'----------------------------------------------------------
Function OpenFilesDialog( BYVAL hWnd AS LONG, _ ' parent window
Caption AS ASCIIZ, _ ' caption
Filespec AS ASCIIZ, _ ' filename (input/output)
InitialDir AS ASCIIZ, _ ' start directory
Filter AS ASCIIZ, _ ' filename filter
DefExtension AS ASCIIZ, _ ' default extension
Flags AS LONG) EXPORT AS LONG ' flags
LOCAL sFile AS STRING
LOCAL Ofn AS OPENFILENAME
LOCAL zFileTitle AS ASCIIZ * 256
LOCAL zFilter AS ASCIIZ * 256
LOCAL zInitialDir AS ASCIIZ * 256
LOCAL zTitle AS ASCIIZ * 256
LOCAL zDefExt AS ASCIIZ * 10
REPLACE "|" WITH CHR$(0) IN Filter
IF LEN(InitialDir) = 0 THEN
InitialDir = CURDIR$
END IF
zFilter = Filter + CHR$(0)
zInitialDir = InitialDir + CHR$(0)
sFile = STRING$(4096,0) 'PLENTY OF ROOM FOR MULTIPLE FILES
MID$(sFile,1) = FileSpec
zDefExt = DefExtension + CHR$(0)
zTitle = Caption + CHR$(0)
ofn.lStructSize = SIZEOF(ofn)
ofn.hWndOwner = hWnd
ofn.lpstrFilter = VARPTR(zFilter)
ofn.nFilterIndex = 1
ofn.lpstrFile = STRPTR(sFile)
ofn.nMaxFile = LEN(sFile)
ofn.lpstrFileTitle = VARPTR(zFileTitle)
ofn.nMaxFileTitle = SIZEOF(zFileTitle)
ofn.lpstrInitialDir = VARPTR(zInitialDir)
IF LEN(zTitle) THEN
ofn.lpstrTitle = VARPTR(zTitle)
END IF
ofn.Flags = Flags
ofn.lpstrDefExt = VARPTR(zDefExt)
FUNCTION = GetOpenFilename(ofn)
Filespec = RTRIM$(sFile,CHR$(0))
Flags = ofn.Flags
END FUNCTION
Visual Basic 3.0 Code
Declare Function OpenFilesDialog Lib "jds.DLL" Alias "OpenFilesDialog" (ByVal hWnd As
Long, ByVal Caption As String, ByVal Filespec As String, ByVal InitialDir As String, ByVal
Filter As String, ByVal DefExtension As String, Flags As Long) As Long
'File Open/Save Dialog Flags
Global Const OFN_READONLY = &H1&
Global Const OFN_OVERWRITEPROMPT = &H2&
Global Const OFN_HIDEREADONLY = &H4&
Global Const OFN_NOCHANGEDIR = &H8&
Global Const OFN_SHOWHELP = &H10&
Global Const OFN_NOVALIDATE = &H100&
Global Const OFN_ALLOWMULTISELECT = &H200&
Global Const OFN_EXTENSIONDIFFERENT = &H400&
Global Const OFN_PATHMUSTEXIST = &H800&
Global Const OFN_FILEMUSTEXIST = &H1000&
Global Const OFN_CREATEPROMPT = &H2000&
Global Const OFN_SHAREAWARE = &H4000&
Global Const OFN_NOREADONLYRETURN = &H8000&
Dim sCaption As String
Dim sFileName As String
Dim sPath As String
Dim sFilter As String
Dim sDefExt As String
Dim lStyle As Long
sCaption = "File Open Test..."
sFileName = Space$(4096)
sFileName = "*.*"
sPath = CurDir$
sFilter = "All Files (*.*)|*.*|Text files (*.TXT, *.BAT)|*.TXT;*.BAT|"
sDefExt = "*.txt"
lStyle = OFN_ALLOWMULTISELECT Or OFN_FILEMUSTEXIST
If OpenFilesDialog(Me.hWnd, sCaption, sFileName, sPath, sFilter, sDefExt, lStyle) Then
'Need to format sFileName
MsgBox "Directory = " & sFileName
Else
MsgBox "No file(s) selected.", MB_OK, "Error"
End If
Comment