"Elliot Tinton EG CEFAS (DN=EJT00, RECIPIENTS, LOWESTOFT, CEFAS)"
wrote:
>
> Can anyone tell me if there is a way to allow the user to specify a directory using
>MapBasic ? Ideally by clicking on the relevant directory in a window showing
>directory structure.
Hi Elliot,
Boy, that's quite a return address you have there! But I
digress...
The way I solved this problem was to create a function called
GetDir() that presents a dialog box that lets the user search
drives and paths and returns either a fully-specified directory
path or a null string. Underneath this, I use the following
Windows API types/functions:
define MAX_PATH 260
define INVALID_HANDLE_VALUE -1
Type FILETIME
dwLowDateTime As integer
dwHighDateTime As integer
End Type
Type WIN32_FIND_DATA
dwFileAttributes As integer
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As integer
nFileSizeLow As integer
dwReserved0 As integer
dwReserved1 As integer
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
declare function GetLogicalDriveString32 lib "kernel32"
alias "GetLogicalDriveStringsA" (
byval nBufferLength as integer,
sBuffer() as integer)
as integer
Declare Function FindFirstFile Lib "kernel32"
Alias "FindFirstFileA" (
ByVal lpFileName As String,
lpFindFileData As WIN32_FIND_DATA)
As integer
Declare Function FindNextFile Lib "kernel32"
Alias "FindNextFileA" (
ByVal hFindFile As integer,
lpFindFileData As WIN32_FIND_DATA)
As integer
Declare Function FindClose Lib "kernel32"
Alias "FindClose" (
ByVal hFindFile As Integer)
As Integer
These don't let you search the desktop, network neighborhood or
the other "new" Win95 paths (if anyone knows how to get to those,
please enlighten me!), but if you set up a mapped network drive,
these functions will work with that as though it was a regular
drive. The trick in gathering up only directory entries after
calling FindFirstFile() or FindNextFile() is to check the
dwFileAttributes element in the returned WIN32_FIND_DATA file
type and if it is 16, that "file" is a directory.
You'll need one of those whopping big WinAPI books to understand
all the details (I'm using the "Visual Basic Programmer's Guide
to the Windows API" by Dan Appleman), but if you want to extend
MapBasic's reach into places you didn't think it could go, this
is a worthwhile investment.
Good luck,
- Bill Thoen
----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]