vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Mails senden, abrufen und decodieren - ganz easy ;-)  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2026
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Re: vb5 ordnerauswahl control? oder code? 
Autor: wincnc
Datum: 25.12.06 01:52

Public Function BrowseForFolder(DialogText As String, _
  DefaultPath As String, _
  OwnerhWnd As Long, _
  Optional ShowCurrentPath As Boolean = True, _
  Optional RootPath As Variant, _
  Optional NewDialogStyle As Boolean = False, _
  Optional IncludeFiles As Boolean = False) As String
 
  Dim biBrowseInfo As BROWSEINFO
  Dim lPIDL As Long
  Dim sBuffer As String
  Dim lBufferPointer As Long
 
  With biBrowseInfo
    .hOwner = OwnerhWnd
 
    If Not IsMissing(RootPath) Then .pidlRoot = PathToPIDL(RootPath)
 
    If ShowCurrentPath And DialogText = "$" Then DialogText = "" ' Wird intern 
    ' nicht zugelassen
    .lpszTitle = DialogText
 
    If ShowCurrentPath Then .pszDisplayName = sBuffer
 
    .ulFlags = BIF_RETURNONLYFSDIRS + _
      IIf(ShowCurrentPath, BIF_STATUSTEXT, 0) + _
      IIf(NewDialogStyle, BIF_NEWDIALOGSTYLE, 0) + _
      IIf(IncludeFiles, BIF_BROWSEINCLUDEFILES, 0)
 
    .lpfnCallback = FARPROC(AddressOf CallbackString)
 
    .lParam = PathToPIDL(DefaultPath)
  End With
 
  lPIDL = SHBrowseForFolder(biBrowseInfo)
 
  If lPIDL Then
    sBuffer = Space$(MAX_PATH)
 
    SHGetPathFromIDList lPIDL, sBuffer
 
    sBuffer = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
 
    BrowseForFolder = sBuffer
 
    Call CoTaskMemFree(lPIDL)
  End If
 
  If ShowCurrentPath Then Call LocalFree(lBufferPointer)
End Function
 
Private Function CallbackString(ByVal hwnd As Long, ByVal uMsg As Long, _
  ByVal lParam As Long, ByVal lpData As Long) As Long
 
  Dim sBuffer As String
  Dim lStaticWnd As Long
  Dim lStaticDC As Long
  Dim sPath As String
  Dim rctStatic As RECT
  Dim szTextSize As Size
 
  Select Case uMsg
  Case BFFM_INITIALIZED
    Call SendMessage(hwnd, BFFM_SETSELECTIONA, False, ByVal lpData)
  Case BFFM_SELCHANGED
    sBuffer = Space$(MAX_PATH)
    If SHGetPathFromIDList(lParam, sBuffer) Then
      SendMessage hwnd, BFFM_SETSTATUSTEXTA, 0&, ByVal "$"
      lStaticWnd = FindWindowEx(hwnd, ByVal 0&, ByVal "Static", ByVal "$")
      lStaticDC = GetWindowDC(lStaticWnd)
      GetWindowRect lStaticWnd, rctStatic
      GetTextExtentPoint lStaticDC, ByVal DIALOG_CURRENT_SELECTION_TEXT, _
        ByVal Len(DIALOG_CURRENT_SELECTION_TEXT), szTextSize
      sPath = sBuffer
      If PathCompactPath(ByVal lStaticDC, sPath, ByVal (rctStatic.Right - _
        rctStatic.Left - szTextSize.cx + 80)) = 0 Then sPath = sBuffer
      sPath = Left$(sPath, InStr(1, sPath, vbNullChar) - 1)
      Call SendMessage(hwnd, BFFM_SETSTATUSTEXTA, 0&, _
        ByVal DIALOG_CURRENT_SELECTION_TEXT & sPath)
    Else
      SendMessage hwnd, BFFM_SETSTATUSTEXTA, 0&, ByVal ""
    End If
  End Select
End Function
 
Private Function FARPROC(FunctionPointer As Long) As Long
  FARPROC = FunctionPointer
End Function
 
Private Function PathToPIDL(ByVal sPath As String) As Long
  Dim lRet As Long
 
  lRet = ILCreateFromPath(sPath)
  If lRet = 0 Then
    sPath = StrConv(sPath, VbStrConv.vbUnicode)
    lRet = ILCreateFromPath(sPath)
  End If
 
  PathToPIDL = lRet
End Function
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
vb5 ordnerauswahl control? oder code?810xverbatim24.12.06 22:58
Re: vb5 ordnerauswahl control? oder code?637wincnc25.12.06 01:51
Re: vb5 ordnerauswahl control? oder code?651wincnc25.12.06 01:52
Re: vb5 ordnerauswahl control? oder code?565xverbatim25.12.06 08:25

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2026 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel