Solved

Is there anyway to center this box when it displays?

Posted on 2001-06-22
6
178 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
  • 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now