Results 1 to 11 of 11

Thread: Browsing Button????

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Browsing Button????

    hi,
    i want to make a button which functionality will be as typical browsing button. plzz guide me regarding that.
    regards,
    fims

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Browsing Button????

    Try this

    VB Code:
    1. Private Type BrowseInfo
    2.     hWndOwner As Long
    3.     pIDLRoot As Long
    4.     pszDisplayName As Long
    5.     lpszTitle As Long
    6.     ulFlags As Long
    7.     lpfnCallback As Long
    8.     lParam As Long
    9.     iImage As Long
    10. End Type
    11. Const BIF_RETURNONLYFSDIRS = 1
    12. Const MAX_PATH = 260
    13. Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    14. Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    15. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    16. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    17. Private Sub Form_Load()
    18.     'KPD-Team 1998
    19.     'URL: [url]http://www.allapi.net/[/url]
    20.     Dim iNull As Integer, lpIDList As Long, lResult As Long
    21.     Dim sPath As String, udtBI As BrowseInfo
    22.  
    23.     With udtBI
    24.         'Set the owner window
    25.         .hWndOwner = Me.hWnd
    26.         'lstrcat appends the two strings and returns the memory address
    27.         .lpszTitle = lstrcat("C:\", "")
    28.         'Return only if the user selected a directory
    29.         .ulFlags = BIF_RETURNONLYFSDIRS
    30.     End With
    31.  
    32.     'Show the 'Browse for folder' dialog
    33.     lpIDList = SHBrowseForFolder(udtBI)
    34.     If lpIDList Then
    35.         sPath = String$(MAX_PATH, 0)
    36.         'Get the path from the IDList
    37.         SHGetPathFromIDList lpIDList, sPath
    38.         'free the block of memory
    39.         CoTaskMemFree lpIDList
    40.         iNull = InStr(sPath, vbNullChar)
    41.         If iNull Then
    42.             sPath = Left$(sPath, iNull - 1)
    43.         End If
    44.     End If
    45.  
    46.     MsgBox sPath
    47. End Sub

  3. #3
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Browsing Button????

    This will open the Browse Dialog Box when the form is loaded.And If you select Any file it will display the filename in the msgbox otherwise it will display a blank msgbox.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: Browsing Button????

    can u please tell me wht its mean?
    VB Code:
    1. With udtBI

  5. #5
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Browsing Button????

    It is a Browers Type Declartion

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: Browsing Button????

    whts this property of form do?
    VB Code:
    1. Me.hWnd

  7. #7
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Browsing Button????

    It will get the Handle(Long Integer) of the Form that you are Using.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: Browsing Button????

    Can u plz guide me abt these lines?

    VB Code:
    1. Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    2. Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    3. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    4. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long

  9. #9
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Browsing Button????

    This are *declarations* (refferers) to some functions (APIs) that are already declared in some libraries somewhere in the system (in that case ole32.dll, kernel32.dll and shell32.dll). To learn more about APIs i suggest you to take a look at AllAPI.net.

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: Browsing Button????

    Can u tell me please that is 'lpIDList' variable tells whether the list can be displayed or not? n how it works?

    thankx for the guidance

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Location
    Pakistan
    Posts
    262

    Re: Browsing Button????

    this code does not select file... access only hierarchy of folders plzzz tell me how can i access file in that specified folder?????????????

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width