]> git.saurik.com Git - wxWidgets.git/commitdiff
Correct making the newly inserted menu item owner drawn in some cases.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 27 Aug 2013 22:49:28 +0000 (22:49 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 27 Aug 2013 22:49:28 +0000 (22:49 +0000)
The item being inserted is not inserted yet when we call
SetOwnerDrawnMenuItem() so we must call it separately for it after inserting
it.

Closes #15437.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74717 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/menu.cpp

index ffdbf8b57dc50dde525c9866c362fc3135c36ca9..f2bcc2000e51673b805a40133ad887af09b6c593 100644 (file)
@@ -542,6 +542,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
 
     // check if we have something more than a simple text item
 #if wxUSE_OWNER_DRAWN
+    bool makeItemOwnerDrawn = false;
     if ( pItem->IsOwnerDrawn() )
     {
 #ifndef __DMC__
@@ -695,6 +696,9 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
                 // set menu as ownerdrawn
                 m_ownerDrawn = true;
 
+                // also ensure that the new item itself is made owner drawn
+                makeItemOwnerDrawn = true;
+
                 ResetMaxAccelWidth();
             }
             // only update our margin for equals alignment to other item
@@ -726,6 +730,12 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
 
             return false;
         }
+
+        if ( makeItemOwnerDrawn )
+        {
+            SetOwnerDrawnMenuItem(GetHmenu(), pos,
+                                  reinterpret_cast<ULONG_PTR>(pItem), TRUE);
+        }
     }