Solved

SHBrowseForFolder or what?

Posted on 2003-11-27
6
901 Views
Last Modified: 2011-09-20
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.PszDisplayName, 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
0
Comment
Question by:EDDYKT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 300 total points
ID: 9833457
HwndOwner member is setted to form2.hwnd?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9833465
Also, there is another parameter when you use vbmodal, i can't remember and  i haven't vb installed to check...
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9833479
it should be

Form2.Show vbModal, me
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Author Comment

by:EDDYKT
ID: 9833501
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

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9833518
I know the feeling. Thanks for "A" grade.
0
 
LVL 26

Author Comment

by:EDDYKT
ID: 9837251
You're welcome


8->
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question