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
Solved

Is there anyway to center this box when it displays?

Posted on 2001-06-22
6
181 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

791 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