Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programmatically rename a qm-item
#1
In an attempt to improve housekeeping of my qm-items folders, I am in need to rename a qm-item using a macro. I understand that renaming is available through a menu command, but this cannot help in automating procedures. Furthermore, use of a newitem statement, to my best knowledge, it does not keep macro's date modified.

Any advice on the procedure to programmatically rename a qm-item will be much appreciated.
#2
I don't know how it is possible with newiten, unless you create new item and delete old item.

This also is not perfect, because may stop working in the future.
Function QmItemRename
Code:
Copy      Help
;/
function $oldName $newName [flags] ;;flags: 1 skip folders, 2 skip shared...

;Renames QM item.

;oldName - used to find the item. Can be name, path, GUID or +id, like with <help>qmitem</help>. Error if QM item not found.
;new name - new name. If not unique, adds a suffix, eg "Abc" -> "Abc2".
;flags - <help>qmitem</help> flags. Used when oldName is name or path.

;REMARKS
;May stop working in some new QM version.
;Does nothing if the QM item is in a read-only folder, or is a read-only folder, or bad id.


int iid
if(oldName<0x10000) iid=oldName; else iid=qmitem(oldName flags)
if(!iid) end "QM item not found"

int c=id(2202 _hwndqm) ;;QM items tree view
NMTVDISPINFOW k.hdr.hwndFrom=c; k.hdr.idFrom=2202; k.hdr.code=TVN_ENDLABELEDITW
k.item.lParam=iid; k.item.pszText=@newName
SendMessageW(GetParent(c) WM_NOTIFY 2202 &k)
#3
Dear Gintaras,

Thank you very much for your advice. I understand, that if it will stop working in a future version, it may be replaced by another appropriate code.

Best regards.


Forum Jump:


Users browsing this thread: 1 Guest(s)