Re: shBrowseForFolder procedure run issue

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Randy Birch (rgb_removethis_at_mvps.org)
Date: 07/10/04

  • Next message: Jacob: "Re: Slidercontrol color and style"
    Date: Fri, 9 Jul 2004 23:19:26 -0400
    
    

    You don't mention specifically if you're using the PIDL or string method,
    but I suspect the string version of the code. Try this modification to the
    way the callback is set ... the routine/code quoted here is the same as from
    my page, so make any appropriate translation if you renamed variables or
    procedures:

    1) Define a new public bas-level string variable called
    sBrowseDlgInitialPath ...

        Private sBrowseDlgInitialPath As String

    2) comment out the following lines in the BrowseForFolderByPath function:

          lpSelPath = LocalAlloc(LPTR, Len(sSelPath) + 1)
          CopyMemory ByVal lpSelPath, ByVal sSelPath, Len(sSelPath) + 1
          .lParam = lpSelPath

    3) add this line in place of the lines above (sSelPath was passed to
    BrowseForFolderByPath as the initial path):

        sBrowseDlgInitialPath = sSelPath

    4) in the BrowseCallbackProcStr function, comment out the line:

             Call SendMessage(hWnd, BFFM_SETSELECTIONA, True, ByVal lpData)

    5) and add this block in its place:

             If (hwnd <> 0) And Len(sBrowseDlgInitialPath) > 0 Then
                DoEvents '<this may not be required
                Call SendMessage(hwnd, BFFM_SETSELECTIONA, 1, ByVal
    sBrowseDlgInitialPath)
             End If

    Here we've removed the passing of the initial folder from the callback's
    lpData member (and removed the need to allocate the memory for that string
    in the call), and simply used the public string variable to set the initial
    path. The lParam member of the BrowseInfo UDT is not used, nor is the lpData
    member of BrowseCallbackProc. I find this always works, whereas I did
    experience a problem with the lpData method on Windows 2000 which prompted
    me to devise this workaround.

    -- 
    Randy Birch
    MVP Visual Basic
    http://vbnet.mvps.org/
    Please respond only to the newsgroups so all can benefit.
    "Arbormead" <Arbormead@discussions.microsoft.com> wrote in message 
    news:501D74F8-70C2-4CD5-8E3C-DE916322F5F9@microsoft.com...
    : I have used the shBrowseForFolder procedure as supplied by Randy Birch at 
    VBNet and have come across a small problem when packaging up the project.
    :
    : Basically the procedure starts at a predefined path as laid out in a text 
    box, the contents of which are loaded at the start.  This works fine with 
    VB6 but when I package up the project and then install it, the same 
    procedure starts at My Computer.  After selecting a path the second time I 
    run it it works fine.  Obviously I would like to run it fine the first time 
    but I'm unsure why this is happening.
    :
    : I have used the VB6 Package and deployment Wizard and also the Visual 
    Studio Installer, both do the same thing.  Is there anywhere else I should 
    be looking to resolve this issue?  I can post the code if required but 
    basically it is a very minor modification od the one I found at 
    http://vbnet.mvps.org/code/callback/browsecallback.htm
    :
    : Let me know if I can provide more information
    :
    : many thanks 
    

  • Next message: Jacob: "Re: Slidercontrol color and style"

    Relevant Pages

    • Re: shBrowseForFolder procedure run issue
      ... "Randy Birch" wrote: ... > but I suspect the string version of the code. ... > Private sBrowseDlgInitialPath As String ... > 2) comment out the following lines in the BrowseForFolderByPath function: ...
      (microsoft.public.vb.controls)
    • Multiple Log Providers
      ... Logs the output from the package to custom tables. ... Dim strPathPkg As String ... Dim pkgChild As New Package ... ByVal sourceName As String, ByVal sourceID As String, ByVal ...
      (microsoft.public.sqlserver.dts)
    • Re: (?{..}) and lexical scoping issues.
      ... > @_ is most definitely a package variable. ... > (You are counting how many substrings of each string are also substrings ... > all substrings of a string. ... it will be hard to beat with a Perl program. ...
      (comp.lang.perl.misc)
    • COM problem calling DTS from vb.net
      ... Select or create a DTS package for use in this test, ... Overridable Overloads Sub OnError(ByVal EventSource As String, ... Overridable Overloads Sub OnFinish_ ...
      (microsoft.public.sqlserver.dts)
    • A simple metaobject protocol for packages
      ... Under this proposal, for each package there is a corresponding class that represents this package. ... A function search-symbol is introduced that behaves similar to find-symbol, except that the string that it is passed is understood to be unmodified, as read for example from source code. ... A corresponding protocol for intern-symbol and intern-symbol-using-class is probably also needed. ...
      (comp.lang.lisp)