Solved

Is there anyway to center this box when it displays?

Posted on 2001-06-22
6
183 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 20 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
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.

 
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

Independent Software Vendors: 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!

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

696 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