Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Dialogue box as modal

Status
Not open for further replies.

LMBag

Technical User
Mar 27, 2003
11
MX
If some one could help that would be great.

I'm opening a diologue box, in order to save a file in a specific folder. I think thi is sopme common dialog control. Any way I got the following code from a previous thread, along with a bit more which I stuck some where else. Any way, it works great, only problem is, it doesn't ope as modal, so a user can click on the form underneath, which is modal and then there is potrential for it to really go wrong. I'm sure that the answer I'm looking for is just a line or slight modification, but i don't really understand all this ADI functuions and ole stuff.

Thanks for any help.


Public Function GetFolder(dlgTitle As String, Frmhwnd As Long, TheForm As Form) As String


Dim intNullChr As Integer
Dim IngIDlist As Long
Dim IngResult As Long
Dim strFolder As String
Dim BI As shellBrowseInfo


With BI
.hwndOwner = Frmhwnd
.IpszTitle = dlgTitle
.uIFlags = BIF_RETURNONLYFSDIRS
End With


IngIDlist = SHBrowseForFolder(BI)
If IngIDlist <> 0 Then
strFolder = String$(MAX_PATH, 0)
IngResult = SHGetPathFromIDList(IngIDlist, strFolder)
Call CoTaskMemFree(IngIDlist) 'frees the ole pointer to InglDlist
intNullChr = InStr(strFolder, vbNullChar)
If intNullChr Then
strFolder = Left$(strFolder, intNullChr - 1)
End If
Else
GetFolder = &quot;Empty&quot;

Exit Function
End If

GetFolder = strFolder


End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top