Databases Reference
In-Depth Information
Windows calls this function when the dialog events occur
Function BrowseCallBackFunc(ByVal hwnd As Long, ByVal msg As
Long, ByVal lParam As Long, ByVal pData As Long) As Long
Select Case msg
Case BFFM_INITIALIZED
'Dialog is being initialized. I use this to set the
initial directory and to center the dialog if the requested
SendMessage hwnd, BFFM_SETSELECTIONA, 1, pData 'Send
message to dialog
If CntrDialog Then CenterDialog hwnd
Case BFFM_SELCHANGED
'User selected a folder - change status text ("show
status text" option must be set to see this)
SendMessage hwnd, BFFM_SETSTATUSTEXTA, 0,
GetPathFromID(lParam)
Case BFFM_VALIDATEFAILED
'This message is sent to the callback function only if
"Allow direct entry" and
'"Validate direct entry" have been be set on the Demo
worksheet
'and the user's direct entry is not valid.
'"Show status text" must be set on to see error message
we send back to the dialog
Beep
SendMessage hwnd, BFFM_SETSTATUSTEXTA, 0, "Bad Directory"
BrowseCallBackFunc = 1 'Block dialog closing
Exit Function
End Select
BrowseCallBackFunc = 0 'Allow dialog to close
End Function
'Converts a PIDL to a string
Function GetPathFromID(ID As Long) As String
Dim Result As Boolean, Path As String * MAX_PATH
Result = SHGetPathFromIDList(ID, Path)
If Result Then
GetPathFromID = Left(Path, InStr(Path, Chr$(0)) - 1)
Else
GetPathFromID = ""
End If
End Function
XL8 is very unhappy about using Excel 9s AddressOf operator, but as long as it is in a
function that is not called when run on XL8, it seems to allow it to exist.
Search WWH ::




Custom Search