Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1448

Renaming Items a la Explorer ;)

$
0
0
Have you ever wondered how the Explorer.exe renaming the folder items when you perform it? Just single renaming so far. But it's powefull ;)
So be care of what you wish ;)
Never BEFORE shown in this forum a la Explorer.exe way to do it!!

Code:

Private Function pOnEndLabelEdit(lParam As LONG_PTR) As Long
  Dim lpTVDI As tagTVDISPINFOEX
  Dim hr As Long
  Dim hWndEdit As Long
  Dim sBuff As String
  Dim pISI As IShellItem
  Dim pISF As IShellFolder
  Dim pIPAI As IParentAndItem
  Dim pidl As LONG_PTR
  Dim pidlOut As LONG_PTR
  Dim lpPath As LONG_PTR
  Dim lpTVIX As tagTVITEMEX
  Dim lpTVHTI As tagTVHITTESTINFO
  Dim lpCurPT As POINTAPI
 
  MoveMemory lpTVDI, ByVal lParam, LenB(lpTVDI)
 
  If lpTVDI.itemex.lParam > 0 Then
    pidl = lpTVDI.itemex.lParam
    Set pISI = m_cShell32.GetIShellItemFromPIDL(pidl)
    If Not pISI Is Nothing Then
      Set pIPAI = pISI
      pIPAI.GetParentAndItem 0, pISF, 0
      pISI.GetDisplayName SIGDN_DESKTOPABSOLUTEPARSING, lpPath
      hWndEdit = pGetEditHandle
      sBuff = String(MAX_PATH, Chr(0))
      GetWindowText hWndEdit, StrPtr(sBuff), LenB(sBuff)
      If MsgBox("The Item you now will rename will be renamed for all times! Do you wanna proceed?", vbExclamation Or vbYesNo, App.Title) = vbYes Then
        hr = pISF.SetNameOf(m_hWndTV, pidl, StrPtr(sBuff), SHGDN_INFOLDER, pidlOut)
        If hr = S_OK Then
          SendMessage m_hWndTV, TVM_ENDEDITLABELNOW, ByVal 0, ByVal 0
          GetCursorPos lpCurPT
          lpTVIX.mask = TVIF_TEXT Or TVIF_PARAM Or TVIF_HANDLE
          lpTVIX.lParam = pidl
          lpTVIX.hTreeItem = lpTVDI.itemex.hTreeItem
          If SendMessage(lpTVDI.hdr.hwndFrom, TVM_GETITEMW, 0, ByVal VarPtr(lpTVIX)) <> 0 Then
            With lpTVIX
                .mask = TVIF_TEXT
                .pszText = StrPtr(sBuff)
            End With
            SendMessage lpTVDI.hdr.hwndFrom, TVM_SETITEMW, 0, ByVal VarPtr(lpTVIX)
            UpdateWindow m_hWndTV
          End If
        Else
          MsgBox "pISF.SetNameOf Failed! Error: #" & Hex(hr), vbExclamation
        End If
      End If
    End If
  End If
  pOnEndLabelEdit = 0
End Function

* m_cShell32 is my cShell32 Class file.

Viewing all articles
Browse latest Browse all 1448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>