sfx2/source/appl/shutdowniconw32.cxx |   28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

New commits:
commit 907fd292c19868b78bcf51ae896e4daffa452ec0
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Dec 29 15:21:07 2021 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 29 14:40:46 2021 +0100

    Small refactor
    
    Use a bit more modern flags with MENUITEMINFOW, and simplify
    MYITEM destruction.
    
    Change-Id: I015e09b875fafcd287bbf45cdc20cf83d2c3e502
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127679
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sfx2/source/appl/shutdowniconw32.cxx 
b/sfx2/source/appl/shutdowniconw32.cxx
index 3c0c62359fe9..13ef8aa07058 100644
--- a/sfx2/source/appl/shutdowniconw32.cxx
+++ b/sfx2/source/appl/shutdowniconw32.cxx
@@ -79,12 +79,12 @@ static void OnDrawItem(HWND hwnd, LPDRAWITEMSTRUCT lpdis);
 
 namespace {
 
-typedef struct tagMYITEM
+struct MYITEM
 {
     OUString text;
     OUString module;
     UINT iconId;
-} MYITEM;
+};
 
 }
 
@@ -95,35 +95,32 @@ static void addMenuItem( HMENU hMenu, UINT id, UINT iconId, 
const OUString& text
     mi.cbSize = sizeof( mi );
     if( id == static_cast<UINT>( -1 ) )
     {
-        mi.fMask=MIIM_TYPE;
+        mi.fMask=MIIM_FTYPE;
         mi.fType=MFT_SEPARATOR;
     }
     else
     {
         if( bOwnerdraw )
         {
-            mi.fMask=MIIM_TYPE | MIIM_STATE | MIIM_ID | MIIM_DATA;
+            mi.fMask=MIIM_FTYPE | MIIM_STATE | MIIM_ID | MIIM_DATA;
             mi.fType=MFT_OWNERDRAW;
-            mi.fState=MFS_ENABLED;
-            mi.wID = id;
 
             MYITEM *pMyItem = new MYITEM;
             pMyItem->text = text;
             pMyItem->iconId = iconId;
             pMyItem->module = module;
-            mi.dwItemData = reinterpret_cast<DWORD_PTR>(pMyItem);
+            mi.dwItemData = reinterpret_cast<ULONG_PTR>(pMyItem);
         }
         else
         {
-            mi.fMask=MIIM_TYPE | MIIM_STATE | MIIM_ID | MIIM_DATA;
-            mi.fType=MFT_STRING;
-            mi.fState=MFS_ENABLED;
-            mi.wID = id;
+            mi.fMask=MIIM_STRING | MIIM_STATE | MIIM_ID;
             mi.dwTypeData = o3tl::toW(
                 const_cast<sal_Unicode *>(text.getStr()));
             mi.cch = text.getLength();
         }
 
+        mi.fState = MFS_ENABLED;
+        mi.wID = id;
         if ( IDM_TEMPLATE == id )
             mi.fState |= MFS_DEFAULT;
     }
@@ -211,18 +208,13 @@ static void deleteSystrayMenu( HMENU hMenu )
         return;
 
     MENUITEMINFOW mi = {};
-    int pos=0;
     mi.cbSize = sizeof( mi );
     mi.fMask = MIIM_DATA;
 
-    while( GetMenuItemInfoW( hMenu, pos++, true, &mi ) )
+    for (UINT pos = 0; GetMenuItemInfoW(hMenu, pos, true, &mi); ++pos)
     {
-        MYITEM *pMyItem = reinterpret_cast<MYITEM*>(mi.dwItemData);
-        if( pMyItem )
-        {
-            pMyItem->text.clear();
+        if (MYITEM* pMyItem = reinterpret_cast<MYITEM*>(mi.dwItemData))
             delete pMyItem;
-        }
         mi.fMask = MIIM_DATA;
     }
 }

Reply via email to