Results 1 to 7 of 7

Thread: Kind of Listbox, like the FileWindow in the Explorer

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4

    Question

    i am searching for a control in a dialog. it should have
    3 columns and above the columns headers. This looks like
    the File-Window in the Windows-Explorer. i tried today the
    standard listbox with multicolumn, but this is not i want.

    but the control is one of the standard controls i think but i don't know which link i must set in the project menue.

    i hope u can help me.

    micki

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    ..try explorer itself

    'code and working example of how to use emplorer's copy
    'dialog box



    Public Declare Function SHFileOperation Lib _
    "shell32.dll" Alias "SHFileOperationA" _
    (lpFileOp As Any) As LongPublic Declare Sub SHFreeNameMappings Lib _
    "shell32.dll" (ByVal hNameMappings As Long)

    Public Declare Sub CopyMemory Lib "KERNEL32" _
    Alias "RtlMoveMemory" (hpvDest As Any, hpvSource _
    As Any, ByVal cbCopy As Long)Public Type SHFILEOPSTRUCT
    hwnd As Long
    wFunc As FO_Functions
    pFrom As String
    pTo As String
    fFlags As FOF_Flags
    fAnyOperationsAborted As Long
    hNameMappings As Long
    lpszProgressTitle As String 'only used if FOF_SIMPLEPROGRESS
    End Type

    Public Enum FO_Functions
    FO_MOVE = &H1
    FO_COPY = &H2
    FO_DELETE = &H3
    FO_RENAME = &H4
    End Enum

    Public Enum FOF_Flags
    FOF_MULTIDESTFILES = &H1
    FOF_CONFIRMMOUSE = &H2
    FOF_SILENT = &H4
    FOF_RENAMEONCOLLISION = &H8
    FOF_NOCONFIRMATION = &H10
    FOF_WANTMAPPINGHANDLE = &H20
    FOF_ALLOWUNDO = &H40
    FOF_FILESONLY = &H80
    FOF_SIMPLEPROGRESS = &H100
    FOF_NOCONFIRMMKDIR = &H200
    FOF_NOERRORUI = &H400
    FOF_NOCOPYSECURITYATTRIBS = &H800
    FOF_NORECURSION = &H1000
    FOF_NO_CONNECTED_ELEMENTS = &H2000
    FOF_WANTNUKEWARNING = &H4000
    End Enum

    Public Type SHNAMEMAPPING
    pszOldPath As String
    pszNewPath As String
    cchOldPath As Long
    cchNewPath As Long
    End Type

    '''''''''''''''''''''''''''''''''''''
    Public Function SHFileOP(ByRef lpFileOp As SHFileOpStruct) As Long
    ' This uses a method suggested at MSKB to
    ' ensure that all parameters are passed correctly
    ' Call this wrapper rather than the API function directly

    Dim result As Long
    Dim lenFileop As Long
    Dim foBuf() As Byte

    lenFileop = LenB(lpFileOp)
    ReDim foBuf(1 To lenFileop) ' the size of the structure.

    ' Now we need to copy the structure into a byte array
    Call CopyMemory(foBuf(1), lpFileOp, lenFileop)

    ' Next we move the last 12 bytes by 2 to byte align the data
    Call CopyMemory(foBuf(19), foBuf(21), 12)
    result = SHFileOperation(foBuf(1))

    SHFileOP = result
    End Function
    ''''''''''''''''''''''''''''''''''''''''''''''''''
    Practical Example

    For example to back up your documents and VB programs to a backup folder, you could use this code:

    Dim lret As Long
    Dim fileop As SHFILEOPSTRUCT

    With fileop
    .hwnd = 0
    .wFunc = FO_COPY
    .pFrom = "C:\Program Files\DevStudio\VB\My Programs" & _
    vbNullChar & "C:\My Documents" & vbNullChar & vbNullChar
    .pTo = "c:\Backup of Documents" & vbNullChar & vbNullChar
    .lpszProgressTitle = "Please wait, backing up..."
    .fFlags = FOF_SIMPLEPROGRESS Or FOF_RENAMEONCOLLISION
    End With

    lret = SHFileOp(fileop)

    If result <> 0 Then ' Operation failed
    MsgBox Err.LastDllError 'Show the error returned from the API.
    Else
    If fileop.fAnyOperationsAborted <> 0 Then
    MsgBox "Operation Failed"
    End If
    End If
    To send this directory to the recycle bin when it is too old, you could use this code:

    Dim lret As Long
    Dim fileop As SHFILEOPSTRUCT

    With fileop
    .hwnd = 0
    .wFunc = FO_DELETE
    .pFrom = "c:\Backup of Documents" & vbNullChar & vbNullChar
    .lpszProgressTitle = "Please wait, backing up..."
    .fFlags = FOF_SIMPLEPROGRESS Or FOF_ALLOWUNDO
    End With

    lret = SHFileOp(fileop)

    If result <> 0 Then ' Operation failed
    MsgBox Err.LastDllError 'Show the error returned from the API.
    Else
    If fileop.fAnyOperationsAborted <> 0 Then
    MsgBox "Operation Failed"
    End If
    End If
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4

    but how i use a control from shell32.dll

    i try to set a link to shell32.dll and a error occurs
    'activex object cannot be registered'

    how i get this explorer control in the dialog-build window?

    micki

  4. #4
    Addicted Member
    Join Date
    Apr 2000
    Location
    Sheffield, England.
    Posts
    136

    Thumbs down

    Erm... instead of all that unnecessary arsing about, just create a "ListView" on your form. It can be found in the Microsoft Common Controls 6 (components).

    Add it to your form, right click it, select 'properties' and change it's type to 'Report View'. Then you can add columns etc.

    Visual Basic 6 Enterprise Edition + SP4

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    4

    Wink aah that works

    hey thanx, that was the thing i searching for.

  6. #6
    Addicted Member
    Join Date
    May 2000
    Location
    Grand Rapids, MI
    Posts
    231

    Exclamation Um API does not = ActiveX

    Just wanted to mention, an API will directly link to the functions of those dlls, like kernel32 and user32 , etc, you do not try to include the DLLs as if they were a ActiveX, which they are not, you use the API calls like he did, (no linking required just paste the code) you can do API with any non-ActiveX dlls, assuming you know the declarations.
    -Karl Blessing aka kb244{fastHACK}
    [email protected]

  7. #7
    Addicted Member
    Join Date
    May 2000
    Location
    Grand Rapids, MI
    Posts
    231

    Talking

    Also Gfk, sometimes the API routine can be much more efficient, smaller and faster than that ActiveX control, sometimes I dont see the point in referencing an ActiveX that has 6 controls , when I only need one, so sometimes the ActiveX are bulkier, in this case of Microsoft Common Controls I wouldnt worry about compatiblity, but with many other activeX controls you would have to distribute them with the application, if I need an ActiveX, I'll make my own with only the features I need.
    -Karl Blessing aka kb244{fastHACK}
    [email protected]

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