Menu

#205 FolderSize: Add context menu in the Files and File Types list views

8
pending
FolderSize (6)
1
2026-04-01
2022-04-03
No

Add a context menu in the Files and Files Types lists.
It can contain a "Open Containing Folder" menu item for the listed files, and also column sorting options.

Related

News: 2022/05/foldersize-110-available

Discussion

  • Vidar Hasfjord

    Vidar Hasfjord - 2022-04-13

    Nice! I've reviewed [r5939] and applied a simplification in [r5947], eliminating unnecessary use of dynamic allocation and pointers for the menu item icons.

    Note that TBitmap is a HBITMAP handle encapsulation. Pointer-to-handle is usually unnecessary indirection. Dynamic allocation and pointers have traditionally been overused in OWL, although for TBitmap, indirection may make sense to avoid the unconventional copy-constructor and its deep-copy semantics. But with modern C++, the copy constructor can be avoided, and hence make indirection unnecessary.

     

    Related

    Commit: [r5939]
    Commit: [r5947]

  • Ognyan Chernokozhev

    • status: open --> pending
     
  • Vidar Hasfjord

    Vidar Hasfjord - 2022-04-19
    • labels: --> FolderSize
     
  • Vidar Hasfjord

    Vidar Hasfjord - 2026-03-31

    Hi @jogybl,

    Note that since the implementation of "Menu bitmap ownership handling" [feature-requests:#262], menus now own their bitmap handles. FolderSize's main menu has been updated for the new ownership model (TMainWindow::GetMenuDescriptor), but the context menus have not (e.g. TFilesListContextMenu). The context menus still keep TBitmap instances to the menu bitmaps, causing double deletion of the bitmap handles.

    While, it seems the double deletion has been harmless, you can simply remove the data members holding TBitmap instances. Instead, create the TBitmap instances locally with the NoAutoDelete flag, just like the GetMenuDescriptor implementations.

    PS. All other uses of SetMenuItemBitmaps throughout the examples seem to have been updated. OWLMaker has been updated as well.

     
    👍
    1

    Related

    Feature Requests: #262

  • Vidar Hasfjord

    Vidar Hasfjord - 2026-04-01

    RGR: FolderSize: Copy-and-paste error in throw-statements [r8735].

    Index: examples/foldersize/foldersize/FolderSizeWnd.cpp
    ===================================================================
    --- examples/foldersize/foldersize/FolderSizeWnd.cpp    (revision 8735)
    +++ examples/foldersize/foldersize/FolderSizeWnd.cpp    (working copy)
    @@ -670,7 +670,7 @@
               auto b = TBitmap{ m.LoadBitmap(TResId{c.first}), NoAutoDelete };
               b.MapColor(TColor::LtGray, TColor::SysMenu);
               const auto res = SetMenuItemBitmaps(c.second, MF_BYCOMMAND, &b); // Menu takes ownership of the handle.
    
    -          if (!res) throw runtime_error("TMainWindow::AssignMenuBitmaps: SetMenuItemBitmaps failed");
    +          if (!res) throw runtime_error(__FUNCTION__": SetMenuItemBitmaps failed");
             }
    
             SetDefaultItem(CM_OPENFILE, false);
    @@ -1080,7 +1080,7 @@
               auto b = TBitmap{ m.LoadBitmap(TResId{c.first}), NoAutoDelete };
               b.MapColor(TColor::LtGray, TColor::SysMenu);
               const auto res = SetMenuItemBitmaps(c.second, MF_BYCOMMAND, &b); // Menu takes ownership of the handle.
    
    -          if (!res) throw runtime_error("TMainWindow::AssignMenuBitmaps: SetMenuItemBitmaps failed");
    +          if (!res) throw runtime_error(__FUNCTION__": SetMenuItemBitmaps failed");
             }
    
             SetDefaultItem(CM_OPENFILE, false);
    @@ -1335,7 +1335,7 @@
               auto b = TBitmap{ m.LoadBitmap(TResId{c.first}), NoAutoDelete };
               b.MapColor(TColor::LtGray, TColor::SysMenu);
               const auto res = SetMenuItemBitmaps(c.second, MF_BYCOMMAND, &b); // Menu takes ownership of the handle.
    
    -          if (!res) throw runtime_error("TMainWindow::AssignMenuBitmaps: SetMenuItemBitmaps failed");
    +          if (!res) throw runtime_error(__FUNCTION__": SetMenuItemBitmaps failed");
             }
           }
         };
    @@ -2136,7 +2136,7 @@
             auto b = TBitmap{ m.LoadBitmap(TResId{c}), NoAutoDelete };
             b.MapColor(TColor::LtGray, TColor::SysMenu);
             const auto res = SetMenuItemBitmaps(c, MF_BYCOMMAND, &b); // Menu takes ownership of the handle.
    -        if (!res) throw runtime_error("TMainWindow::AssignMenuBitmaps: SetMenuItemBitmaps failed");
    +        if (!res) throw runtime_error(__FUNCTION__": SetMenuItemBitmaps failed");
           }
         }
       };
    Index: examples/foldersize/foldersize/main.cpp
    ===================================================================
    --- examples/foldersize/foldersize/main.cpp (revision 8735)
    +++ examples/foldersize/foldersize/main.cpp (working copy)
    @@ -140,7 +140,7 @@
           auto b = TBitmap{a.LoadBitmap(TResId{c}), NoAutoDelete};
           b.MapColor(TColor::LtGray, TColor::SysMenu);
           const auto res = m->SetMenuItemBitmaps(c, MF_BYCOMMAND, &b); // Menu takes ownership of the handle.
    -      if (!res) throw runtime_error("TMainWindow::AssignMenuBitmaps: SetMenuItemBitmaps failed");
    +      if (!res) throw runtime_error(__FUNCTION__": SetMenuItemBitmaps failed");
         }
         return m;
       }
    
     

    Related

    Commit: [r8735]

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB