|
-
Nov 9th, 2004, 06:28 PM
#1
Thread Starter
Fanatic Member
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:
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
-
Nov 9th, 2004, 06:50 PM
#2
Software Eng.
Or combines flags.
Perhaps the two flags are not allowed to co-exist?
Can you post your code for this routine?
-
Nov 9th, 2004, 08:39 PM
#3
Thread Starter
Fanatic Member
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:
'Form method:
Private Sub BrowseFolder()
'Displays BrowseForFolder dialog
Dim dlgBrowse As BrowseInfo
Dim strPath As String
Dim lngResult As Long
dlgBrowse.hwndOwner = Me.hWnd
dlgBrowse.lpszTitle = lstrcat("Selecteer de map waarin u uw documenten wilt opslaan.", "")
dlgBrowse.ulFlags = BIF_NEWDIALOGSTYLE Or BIF_RETURNONLYFSDIRS
lngResult = SHBrowseForFolder(dlgBrowse)
If lngResult <> 0 Then
strPath = String$(MAX_PATH, 0)
SHGetPathFromIDList lngResult, strPath
CoTaskMemFree lngResult
If InStr(strPath, vbNullChar) <> 0 Then
strPath = Left$(strPath, InStr(strPath, vbNullChar) - 1)
End If
lblSave.Caption = strPath
End If
End Sub
VB Code:
'Module declarations:
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Public 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
Public Const BIF_RETURNONLYFSDIRS = 1
Public Const MAX_PATH = 260
Public Const BIF_NEWDIALOGSTYLE = &H40
Public Const BIF_STATUSTEXT = &H4
Public Const BIF_EDITBOX = &H10
Public Const BIF_UAHINT = &H100
Author for Visual Basic Web Magazine
-
Nov 9th, 2004, 09:59 PM
#4
Software Eng.
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
-
Nov 10th, 2004, 05:59 AM
#5
Thread Starter
Fanatic Member
It's strange. I've decided to check the return value as you suggested.
Thanks for your help.
Author for Visual Basic Web Magazine
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|