EDDYKT
asked on
SHBrowseForFolder or what?
Create a simple standard exe and add 2 forms. On each form add 1 command button
On form1
Option Explicit
Private Sub Command1_Click()
Form2.Show vbModal
End Sub
On form2
Option Explicit
'''''''''''''''''''''''''' '''''''''' '''''''''' '''''''''' '''''''''' '''''''''' '''
' private variables declaration
Private Type BROWSEINFO
HwndOwner As Long
PidlRoot As Long
PszDisplayName As String
LpszTitle As String
UlFlags As Long
Lpfn As Long
lParam As Long
IImage As Long
End Type
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Private Sub Command1_Click()
Dim Info As BROWSEINFO
On Error Resume Next
Info.PidlRoot = &H12
Info.LpszTitle = "Select Computer Name:"
Info.UlFlags = &H1000
Info.PszDisplayName = Space$(256)
SHBrowseForFolder Info
If (Asc(Mid$(Info.PszDisplayN ame, 1, 1)) <> 32) Then
Debug.Print Left(Info.PszDisplayName, InStr(Info.PszDisplayName, Chr$(0)) - 1)
Else
Exit Sub
End If
End Sub
When I click on form2 button, SHBrowseForFolder starts up and wait for user input.
However, I still can click on form2 and even exit the form1 and let the program hanging there if I don't touch the SHBrowseForFolder. How do I prevent this. I would like the user cannot exit the form1 or form2 without selecting the path
On form1
Option Explicit
Private Sub Command1_Click()
Form2.Show vbModal
End Sub
On form2
Option Explicit
''''''''''''''''''''''''''
' private variables declaration
Private Type BROWSEINFO
HwndOwner As Long
PidlRoot As Long
PszDisplayName As String
LpszTitle As String
UlFlags As Long
Lpfn As Long
lParam As Long
IImage As Long
End Type
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Private Sub Command1_Click()
Dim Info As BROWSEINFO
On Error Resume Next
Info.PidlRoot = &H12
Info.LpszTitle = "Select Computer Name:"
Info.UlFlags = &H1000
Info.PszDisplayName = Space$(256)
SHBrowseForFolder Info
If (Asc(Mid$(Info.PszDisplayN
Debug.Print Left(Info.PszDisplayName, InStr(Info.PszDisplayName,
Else
Exit Sub
End If
End Sub
When I click on form2 button, SHBrowseForFolder starts up and wait for user input.
However, I still can click on form2 and even exit the form1 and let the program hanging there if I don't touch the SHBrowseForFolder. How do I prevent this. I would like the user cannot exit the form1 or form2 without selecting the path
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, there is another parameter when you use vbmodal, i can't remember and i haven't vb installed to check...
it should be
Form2.Show vbModal, me
Form2.Show vbModal, me
ASKER
Sometime long hour work will drive you crazy and cannot think
>>Form2.Show vbModal, me
doesn't work
but
HwndOwner member is setted to form2.hwnd?
works
8->
Thanks
>>Form2.Show vbModal, me
doesn't work
but
HwndOwner member is setted to form2.hwnd?
works
8->
Thanks
I know the feeling. Thanks for "A" grade.
ASKER
You're welcome
8->
8->