Results 1 to 6 of 6

Thread: BrowseForFolder and Editbox and events

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    244

    BrowseForFolder and Editbox and events

    Hi,
    I've searched these forums but I couldn't find a topic which already discusses this.

    With the BrowseForFolder you can enable the Editbox, but it seems there is no direct callback (using the same callback as the BFFM_INITIALIZED and BFFM_SELCHANGED are handled) when a user enters text.
    If I have the OK button disabled (through some check during callback BFFM_SELCHANGED) and a user types something, the button is automatically enabled again (until the user deleted all text in the editbox) without me getting any events not until the user pushes <enter> or tries the <OK> button, then if it's an nonexisting folder it will trigger the BFFM_VALIDATEFAILEDA event, but if the folder exists it closes the window (but I want/have the OK button disabled (during BFFM_SELCHANGED) because there isn't a specific file in the folder).
    Is there a flag to get a BFFM_???? event during typing or is the only way to do it by setting up a callback myself by hooking into the editbox window?

    I do see a BFFM_SELCHANGED when the folder exists and the user has pushed enter or the OK button, but I don't seem to be able to block the dialog from closing during that event, which for BFFM_VALIDATEFAILEDA is as easy as just letting the callback return 1. So another option would be to block the dialog from closing during BFFM_SELCHANGED, but how?

  2. #2
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,719

    Re: BrowseForFolder and Editbox and events

    Would disabling the OK with BFFM_ENABLEOK during BFFM_SELCHANGED work? If not yeah you're going to have to hook in deeper.

    Or if XP support isn't important, the newer IFileDialog-based folder picker offers a far greater level of control.

  3. #3
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,259

    Re: BrowseForFolder and Editbox and events

    Quote Originally Posted by SuperDre View Post
    ...So another option would be to block the dialog from closing during BFFM_SELCHANGED, but how?
    I also don't get any "EditBox-changed-Events" in the RC5-implementation, but I can cancel
    the closing from within the Callback - not sure if that would suit your needs?

    In case you want to play around with the following RC5-snippet - and its behaviour could solve your problem,
    I could look into the code, to tell you what I've done there (API-wise).

    Code:
    Option Explicit
    
    Private WithEvents BFF As cFSO
    
    Private Sub Form_Click()
      Set BFF = New_c.FSO(True)
      Debug.Print BFF.ShowFoldersDialog("MyTitle", "C:\Code", , , BIF_USENEWUI Or BIF_VALIDATE Or BIF_EDITBOX Or BIF_BROWSEINCLUDEFILES, Me.hWnd)
    End Sub
    
    Private Sub BFF_BrowseFolderChange(CurSelection As String, DisableOkBtn As Boolean, OKButtonCaption As String, ByVal EditStringToValidate As String, KeepDialogOpen As Boolean)
    '  OKButtonCaption = "Something else than OK"
      Debug.Print "BrowseFolderChange-Callback", CurSelection, EditStringToValidate
    '  DisableOkBtn = Not New_c.FSO.FolderExists("...")
    '  DisableOkBtn = Not New_c.FSO.FileExists("...")
    '  DisableOkBtn = Not New_c.FSO.DirectoryHasSubDirs("...")
      If EditStringToValidate <> "xyz" Then KeepDialogOpen = True
    End Sub
    Olaf

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    244

    Re: BrowseForFolder and Editbox and events

    Quote Originally Posted by fafalone View Post
    Would disabling the OK with BFFM_ENABLEOK during BFFM_SELCHANGED work? If not yeah you're going to have to hook in deeper.

    Or if XP support isn't important, the newer IFileDialog-based folder picker offers a far greater level of control.
    Setting the OK button to disabled doesn't (sadly) block the dialog from closing, I already use the BFFM_ENABLEDOK in BFFM_SELCHANGED for when one selects another folder using the mouse, but I wanted to add the editbox option for when the server is not visible but available. Also tried to let the callback return 1 during BFFM_SELCHANGED, but according to the API documentation (and testing) it only works for BFFM_VALIDATIONFAILED.
    There are still some users which use XP so IFileDialog is not an option (at this time).

    Quote Originally Posted by Schmidt View Post
    I also don't get any "EditBox-changed-Events" in the RC5-implementation, but I can cancel
    the closing from within the Callback - not sure if that would suit your needs?

    In case you want to play around with the following RC5-snippet - and its behaviour could solve your problem,
    I could look into the code, to tell you what I've done there (API-wise).

    Olaf
    Where can I get the cFSO class? or a sneakpeak at what you do to prevent the dialog from closing. Maybe you have some extra hooks beside the standard callback.

  5. #5
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,259

    Re: BrowseForFolder and Editbox and events

    Quote Originally Posted by SuperDre View Post
    Where can I get the cFSO class?
    Sorry, mistakenly thought you were one of the "longterm-RC5-Users"...
    cFSO is part of the vbRichClient5-lib (downloadable from vbRichClient.com).

    Quote Originally Posted by SuperDre View Post
    or a sneakpeak at what you do to prevent the dialog from closing. Maybe you have some extra hooks beside the standard callback.
    Could now reproduce what you meant (with no "KeepOpen-reaction" when the EditBox-content was not changed) -
    in that case the older version of the cFSO also did always close the Dialogue (on pressing "OK"),
    without honoring the KeepDialogOpen-ByRef-Param of the Event.

    I was able to change that behaviour now though with relative ease (in the new version 5.0.53 of the RC5) -
    without extra-hooking or anything - it was enough, to do within:
    Case BFFM_SELCHANGED
    ...determine the Edit-Hwnd per FindWindowEx
    ...if found, then SendMessage EditHwnd, WM_SETTEXT to the split-off remainder of the current path
    ...that in turn seems to change the Dialogues internal "IsDirty"-Flag (although it only re-sets the EditContent to what was already there)
    ...then in turn, the BFFM_VALIDATIONFAILED is always raised - and the KeepOpen will work (by setting the Callback-ReturnValue to 1)

    HTH

    Olaf

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    244

    Re: BrowseForFolder and Editbox and events

    Quote Originally Posted by Schmidt View Post
    I was able to change that behaviour now though with relative ease (in the new version 5.0.53 of the RC5) -
    without extra-hooking or anything - it was enough, to do within:
    Case BFFM_SELCHANGED
    ...determine the Edit-Hwnd per FindWindowEx
    ...if found, then SendMessage EditHwnd, WM_SETTEXT to the split-off remainder of the current path
    ...that in turn seems to change the Dialogues internal "IsDirty"-Flag (although it only re-sets the EditContent to what was already there)
    ...then in turn, the BFFM_VALIDATIONFAILED is always raised - and the KeepOpen will work (by setting the Callback-ReturnValue to 1)

    Olaf
    Thanx Olaf, I will try that.

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