diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index d74f536cf2..8626a56849 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -225,8 +225,10 @@ bool wxComboBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) WXHWND wxComboBox::GetEditHWND() const { - if ( GetWindowStyle() & wxCB_READONLY ) - return NULL; + // this function should not be called for wxCB_READONLY controls, it is + // the callers responsability to check this + wxASSERT_MSG( !(GetWindowStyle() & wxCB_READONLY), + _T("read-only combobox doesn't have any edit control") ); POINT pt; pt.x = pt.y = 4; diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 0e1cdfc829..9a324b1042 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -417,71 +417,50 @@ void wxFrame::PositionStatusBar() void wxFrame::DetachMenuBar() { - if (m_frameMenuBar) + if ( m_frameMenuBar ) { m_frameMenuBar->Detach(); m_frameMenuBar = NULL; } } -void wxFrame::SetMenuBar(wxMenuBar *menu_bar) +void wxFrame::SetMenuBar(wxMenuBar *menubar) { - if (!menu_bar) + if ( !menubar ) { DetachMenuBar(); - //actually remove the menu from the frame - m_hMenu=NULL; + + // actually remove the menu from the frame + m_hMenu = (WXHMENU)0; InternalSetMenuBar(); - return; } - - m_frameMenuBar = NULL; - - // Can set a menubar several times. - // TODO: how to prevent a memory leak if you have a currently-unattached - // menubar? wxWindows assumes that the frame will delete the menu (otherwise - // there are problems for MDI). - if (menu_bar->GetHMenu()) + else // set new non NULL menu bar { - m_hMenu = menu_bar->GetHMenu(); + m_frameMenuBar = NULL; + + // Can set a menubar several times. + // TODO: how to prevent a memory leak if you have a currently-unattached + // menubar? wxWindows assumes that the frame will delete the menu (otherwise + // there are problems for MDI). + if ( menubar->GetHMenu() ) + { + m_hMenu = menubar->GetHMenu(); + } + else + { + menubar->Detach(); + + m_hMenu = menubar->Create(); + + if ( !m_hMenu ) + return; + } + + InternalSetMenuBar(); + + m_frameMenuBar = menubar; + menubar->Attach(this); } - else - { - menu_bar->Detach(); - - m_hMenu = menu_bar->Create(); - - if ( !m_hMenu ) - return; - } - - InternalSetMenuBar(); - - m_frameMenuBar = menu_bar; - menu_bar->Attach(this); - -#if 0 // Old code that assumes only one call of SetMenuBar per frame. - if (!menu_bar) - { - DetachMenuBar(); - return; - } - - wxCHECK_RET( !menu_bar->GetFrame(), wxT("this menubar is already attached") ); - - if (m_frameMenuBar) - delete m_frameMenuBar; - - m_hMenu = menu_bar->Create(); - - if ( !m_hMenu ) - return; - - InternalSetMenuBar(); - - m_frameMenuBar = menu_bar; - menu_bar->Attach(this); -#endif } void wxFrame::InternalSetMenuBar() diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 9bbb661b03..73e8d4d856 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -2195,7 +2195,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) if ( tvhti.flags & TVHT_ONITEM ) { event.m_item = (WXHTREEITEM) tvhti.hItem; - eventType = hdr->code == NM_DBLCLK + eventType = (int)hdr->code == NM_DBLCLK ? wxEVT_COMMAND_TREE_ITEM_ACTIVATED : wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK; }