Results 1 to 5 of 5

Thread: Combining flags

  1. #1

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Resolved Combining flags

    Hi,

    Sorry for the stupidity of the question, but I'm really stuck. I want to combine two flags in a BrowseInfo structure that is used with the SHBrowseForFolder API.
    VB Code:
    1. dlgBrowse.ulFlags = BIF_NEWDIALOGSTYLE [b]And[/b] BIF_RETURNONLYFSDIRS
    Independently they work, but together they don't. I've tried 'And', 'Or', +, and &, but I can't get it to work. How can I combine those flags?

    Thanks.
    Last edited by TheVader; Nov 20th, 2004 at 08:20 AM.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  2. #2
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Or combines flags.

    Perhaps the two flags are not allowed to co-exist?

    Can you post your code for this routine?

  3. #3

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Is it Or? That's odd, it doesn't seem to work.

    Here is the routine I use to call the BrowseForFolder dialog. The BIF_NEWDIALOGSTYLE gives the dialog a modern look, with mouseover effects etc. The BIF_RETURNONLYFSDIRS flag makes sure the user can only select directories (so not My Computer e.g.). Independently they work, together they don't... thanks for the help.
    VB Code:
    1. 'Form method:
    2. Private Sub BrowseFolder()
    3. 'Displays BrowseForFolder dialog
    4. Dim dlgBrowse As BrowseInfo
    5. Dim strPath As String
    6. Dim lngResult As Long
    7.  
    8. dlgBrowse.hwndOwner = Me.hWnd
    9. dlgBrowse.lpszTitle = lstrcat("Selecteer de map waarin u uw documenten wilt opslaan.", "")
    10. dlgBrowse.ulFlags = BIF_NEWDIALOGSTYLE Or BIF_RETURNONLYFSDIRS
    11.  
    12. lngResult = SHBrowseForFolder(dlgBrowse)
    13.  
    14. If lngResult <> 0 Then
    15.     strPath = String$(MAX_PATH, 0)
    16.     SHGetPathFromIDList lngResult, strPath
    17.     CoTaskMemFree lngResult
    18.        
    19.     If InStr(strPath, vbNullChar) <> 0 Then
    20.         strPath = Left$(strPath, InStr(strPath, vbNullChar) - 1)
    21.     End If
    22.    
    23.     lblSave.Caption = strPath
    24. End If
    25. End Sub
    VB Code:
    1. 'Module declarations:
    2. Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    3. Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    4. Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    5. Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    6.  
    7. Public Type BrowseInfo
    8.     hwndOwner As Long
    9.     pIDLRoot As Long
    10.     pszDisplayName As Long
    11.     lpszTitle As Long
    12.     ulFlags As Long
    13.     lpfnCallback As Long
    14.     lParam As Long
    15.     iImage As Long
    16. End Type
    17.  
    18. Public Const BIF_RETURNONLYFSDIRS = 1
    19. Public Const MAX_PATH = 260
    20. Public Const BIF_NEWDIALOGSTYLE = &H40
    21. Public Const BIF_STATUSTEXT = &H4
    22. Public Const BIF_EDITBOX = &H10
    23. Public Const BIF_UAHINT = &H100
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  4. #4
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Tried it; doesn't look like you can.

    As a word around, you could validate the the return value (If Len(strPath) = 0 Then...)

    You could also look into custom filters. More info about these can be found Here

  5. #5

    Thread Starter
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    It's strange. I've decided to check the return value as you suggested.

    Thanks for your help.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

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