[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Is there anyway to center this box when it displays?

Posted on 2001-06-22
6
Medium Priority
?
186 Views
Last Modified: 2010-05-02
20 for a no 100 for a hook that works

'Using the browser dialog box
'make a reference

Option Explicit

Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260

Private Declare Function SHBrowseForFolder Lib _
"shell32" (lpbi As BrowseInfo) As Long

Private Declare Function SHGetPathFromIDList Lib _
"shell32" (ByVal pidList As Long, ByVal lpBuffer _
As String) As Long

Private Declare Function lstrcat Lib "kernel32" _
Alias "lstrcatA" (ByVal lpString1 As String, ByVal _
lpString2 As String) As Long

Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type




Private Sub Form_Load()
'Opens a Browse Folders Dialog Box that displays the
'directories in your computer
Dim lpIDList As Long ' Declare Varibles
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo

szTitle = "Hello World. Click on a directory and " & _
"it's path will be displayed in a message box"
' Text to appear in the the gray area under the title bar
' telling you what to do

With tBrowseInfo
.hWndOwner = Me.hWnd ' Owner Form
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End With

lpIDList = SHBrowseForFolder(tBrowseInfo)

If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)

' <<< Add Your Code Here >>> 

MsgBox sBuffer

End If
End Sub
0
Comment
Question by:vbWayne
[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 15

Expert Comment

by:ameba
ID: 6218542
In Q 10232671 (21 pts) caraf_g wrote:
>I've modified your code slightly, so now in the browseforfolder procedure you pass in an "Owner" window and a relative Left and Top position. The Browse For Folder dialog is then positioned nicely.
And there is his code which uses MoveWindow...
0
 
LVL 1

Author Comment

by:vbWayne
ID: 6218811
How do I get to it...if I seach Q 10232671 it returns nothing.
0
 
LVL 15

Accepted Solution

by:
ameba earned 80 total points
ID: 6218847
Hi, here is the link - code is in caraf_g's comment near the bottom of the thread
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10232671
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 15

Expert Comment

by:ameba
ID: 6218903
If it works, feel free to delete this question.  I got enough B grades already.  (This is probably for B grade by using stupid ee practice - 'do the work for me')
0
 
LVL 1

Author Comment

by:vbWayne
ID: 6227898
I don't give B unless the answer is somewhere around the bend. I couldn't get it to behave as I wanted as for some reason I can't seem to talk to it. I tried the set window api but again I can't seem to get it to respone...anyway, I can live with the situtation and it's not worth spending more time on it.

Thanks...
Sorry for the late reply..been away and the 20 is for an answer I couldn't get working.

0
 
LVL 15

Expert Comment

by:ameba
ID: 6228227
I tested it and caraf_g's module works, e.g.:

' test form
Option Explicit

Private Sub Form_Click()
    ' to position dialog, change lngLeft and lngTop parameters
    BrowseForFolder Me, "c:\", "Prompt:", 150, 150
End Sub
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

650 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