X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/906c935a80b10d53cecf57f71ab5f3f4f1d529ec..74a8f67d96591cec101def2a7d47c64072aff7fd:/src/msw/menu.cpp diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index c1accd90e2..fe8b4a51dd 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -260,7 +260,7 @@ inline bool IsGreaterThanStdSize(const wxBitmap& bmp) // --------------------------------------------------------------------------- // Construct a menu with optional title (then use append) -void wxMenu::Init() +void wxMenu::InitNoCreate() { m_radioData = NULL; m_doBreak = false; @@ -270,6 +270,11 @@ void wxMenu::Init() m_maxBitmapWidth = 0; m_maxAccelWidth = -1; #endif // wxUSE_OWNER_DRAWN +} + +void wxMenu::Init() +{ + InitNoCreate(); // create the menu m_hMenu = (WXHMENU)CreatePopupMenu(); @@ -287,6 +292,24 @@ void wxMenu::Init() } } +wxMenu::wxMenu(WXHMENU hMenu) +{ + InitNoCreate(); + + m_hMenu = hMenu; + + // Ensure that our internal idea of how many items we have corresponds to + // the real number of items in the menu. + // + // We could also retrieve the real labels of the items here but it doesn't + // seem to be worth the trouble. + const int numExistingItems = ::GetMenuItemCount(m_hMenu); + for ( int n = 0; n < numExistingItems; n++ ) + { + wxMenuBase::DoAppend(wxMenuItem::New(this, wxID_SEPARATOR)); + } +} + // The wxWindow destructor will take care of deleting the submenus. wxMenu::~wxMenu() {