Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Okay, I understand VB.net coding pretty well. But, I am stuck... I decided to make a search program for my first .NET program. There are two things I am stuck doing...

 

1. Trying to open a Browse for Folder window:

 

Module BrowseFolder
   'Open Folder
   Private Const BIF_RETURNONLYFSDIRS = 1
   Private Const BIF_DONTGOBELOWDOMAIN = 2
   Private Const MAX_PATH = 260

   Private Structure BrowseInfo
       Dim hwndOwner As IntPtr
       Dim pIDLRoot As Long
       Dim pszDisplayName As Long
       Dim lpszTitle As Long
       Dim ulFlags As Long
       Dim lpfnCallback As Long
       Dim lParam As Long
       Dim iImage As Long
   End Structure

   Private Declare Function SHBrowseForFolder Lib "shell32" (ByVal 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

   Public Function OpenDirectoryTV(ByVal odtvOwner As Form, ByVal odtvTitle As String) As String
       Dim lpIDList As Long
       Dim sBuffer As String
       Dim szTitle As String
       Dim tBrowseInfo As BrowseInfo

       szTitle = odtvTitle

       With tBrowseInfo
           .hwndOwner = odtvOwner.Handle
           .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)
           OpenDirectoryTV = sBuffer
       End If
   End Function
End Module

 

The program gets stuck at "lpIDList = SHBrowseForFolder(tBrowseInfo)" but I have absolutely no clue why...

 

2. VB6 had the file list box that you could use to loads files from a directory into. Is there a similiar control or method to do this in Vb.net. Keeping in mind that the program I am trying to make has to filter files according to their extension.... like search just .mp3 file or search just .mp3 and .mpg files, etc...

 

Thanks.. :)

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...