Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get current active item
#1
Is it possible to get the current active item (the clicked item in the item list at the left, which is marked blue when clicked on)

What I know:

Function get_current
Code:
Copy      Help
;; 1 --- Get current item, is not a real option because when running this code
;; it always get's the name of THIS item ("get_current")
str cur_qmitem.getmacro(getopt(itemid) 1)

;; 2 --- Get calling item ("f" contains calling item)
;; Only works when calling THIS item name ("get_current")
str fs f; GetCallStack &fs 3 ;; 3=flags 1 AND 2
f.getl(fs 1)

;; 3 --- From the "Open items" list, get the most TOP item ("s" contains topmost item)
;; This is the only working option with one problem: it can contain partial (truncated) strings
int wMain=win("Quick Macros" "QM_Editor")
int w=id(2212 wMain) ;;list
RECT r; SetRect &r 17 -2 124 19
WindowText wt.Init(w r)
str s=wt.CaptureToString

;; 4 --- does not work
QMITEM q
SendMessage(id(2202 w) TVM_GETITEMW 0 &q)
out q.name

Only option 3 works, when putting that code in a macro/function which is placed on a toolbar.
Pressing that macro/function on the toolbar get's the correct current clicked item.
The problem is that it can retrieve turncated/partial item names (because the 'open items' window may have small dimensions).
#2
To get current non-folder item, call qmitem or str.getmacro with name "".
Code:
Copy      Help
QMITEM q
int iid=qmitem("" 0 q 1)
out iid
out q.name

To get current selected item, which can be folder, use treeview control messages.
Code:
Copy      Help
;get selected treeview item and its lparam, which is QM item id
int c=id(2202 _hwndqm) ;;outline
TVITEMW m.hItem=SendMessage(c TVM_GETNEXTITEM TVGN_CARET 0)
SendMessage(c TVM_GETITEMW 0 &m)
;get name
QMITEM q
int iid=qmitem(m.lParam 0 q 1)
out iid
out q.name
#3
Thank you!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)