Two questions about Project Panel and Docked Windows

  • Hi all!

    Maybe I overlooked something, but I don’t seem to find answers to the following dev questions:

    1. The Project Panel / Folder as Workspace.
      How can a plugin retrieve the root path to the workspace files?
      For an example of what it might be needed for, please look at this feature request:

    2. The Docked Panels (Windows) switching/activating.
      How can one programmatically activate/switch to a desired docked panel/window?
      For an example of what it might be needed for, please look at this feature request:


  • @Vitalii-Dovgan

    there is no builtin npp message which can be used but for

    1. enumerate the child windows for File Browser and then find its SysTreeView32 and us TVM messages to get the needed information
      and for
    2. should be the same, enumerate to find your console window and get its associated systabcontrol …

  • @Vitalii-Dovgan

    I had some time to do a little experiment and it looks like
    you can use something similar like the python scripts I’ve used.

    to get the path for each root node from File Browser:

    def enum_root_pathes(hwnd, lParam):
        if gui.IsWindowVisible(hwnd):
            name = gui.GetWindowText(hwnd)
            if name == 'File Browser':
                h_systreeview32 = gui.FindWindowEx(hwnd, None , 'SysTreeView32', None)
                if h_systreeview32:
                    root_nodes = []
                    hNode = gui.SendMessage(h_systreeview32,
                    while hNode:
                        nextNode = gui.SendMessage(h_systreeview32,
                        hNode = nextNode
                    for node in root_nodes:
                        tvitem, extras = gui_struct.EmptyTVITEM(node)
                        res = gui.SendMessage(h_systreeview32,
                        if res:
                            _, _, _, _, _, _, _, param = gui_struct.UnpackTVITEM(tvitem)                
                            x = ctypes.c_wchar_p.from_address(param)
        return True
    gui.EnumChildWindows(notepad.hwnd, enum_root_pathes, None)

    To switch to a know/active tab in a docked dialog

    NPPM_DMMVIEWOTHERTAB = 1024+1000+35

    to enumerate the current open tabs of docked dialogs,
    I had only partial success. It looks like either the docking manager
    corrupts the tab structure, there is a bug in SysTabControl or, likely,
    I haven’t understood how to use it correctly.

    def enum_tabs(hwnd, lParam):
        if gui.IsWindowVisible(hwnd):
            window_name = gui.GetWindowText(hwnd)
            # class_name = gui.GetClassName(hwnd)
            # if class_name != 'Scintilla':
                # print(window_name, class_name)
            if window_name == 'Tab1':
                open_tabs = gui.SendMessage(hwnd, com.TCM_GETITEMCOUNT, 0,0)
                for i in range(open_tabs):
                    # tcitem, extras = create_TCITEM_structure()
                    tcitem, extras = create_TCITEMHEADER_structure()
                    # res = gui.SendMessage(hwnd, com.TCM_SETCURSEL, i, 0) 
                    # print('res', res)
                    res = gui.SendMessage(hwnd, com.TCM_GETITEMW, i, tcitem)
                    if res:
                        _, _, _, pszText, _, _, = struct.unpack('IiiPii', tcitem)
                        print(i, gui.PyGetString(pszText))
        return True
    gui.EnumChildWindows(notepad.hwnd, enum_tabs, None)

    This correctly identifies the number of tabs used but it only reports
    the tab caption for the last dialog attached to the tab control.
    Maybe helpful anyway.

  • Thank you, I’ll try it!

Log in to reply