Solved

Is there anyway to center this box when it displays?

Posted on 2001-06-22
6
179 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DO Loop not working 4 72
Windows 10 start screen issues 9 51
JSON Response and request in VB6 application 11 235
Can we place a tooltip on the actual vb6 form 5 35
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

929 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

13 Experts available now in Live!

Get 1:1 Help Now