Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. problem with CSplitButton::SetDropDownMenu method

problem with CSplitButton::SetDropDownMenu method

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++visual-studiodebugging
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    A Ms
    wrote on last edited by
    #1

    Hi, I have created a dialog based application in visual studio 2010 and I have added a CSplitButton Control to my dialog through resource editor, also I have made a menu in resource editorwith the ID of IDR_MENU_BUTTON_FILE and a sud menu after all, my code looks like the following code:

    BOOL CMyDialogDlg::OnInitDialog()
    {
    CSplitButton* pCtrlSpiltBtn = (CSplitButton*)this->GetDlgItem(IDC_SPLITBUTTON1);
    pCtrlSpiltBtn ->SetDropDownMenu(IDR_MENU_BUTTON_FILE, 0);
    }

    however the pCtrlSpiltBtn get initialized correctly and every thing is OK. but

    pCtrlSpiltBtn ->SetDropDownMenu(IDR_MENU_BUTTON_FILE, 0);

    fails when I trace the case I found that this line call the following methods of MFC classes.

    void CSplitButton::SetDropDownMenu(UINT nMenuId, UINT nSubMenuId)
    {
    Cleanup();
    m_nMenuId = nMenuId;
    m_nSubMenuId = nSubMenuId;
    }

    void CSplitButton::SetDropDownMenu(CMenu* pMenu)
    {
    Cleanup();
    m_pMenu = pMenu;
    }

    void CSplitButton::Cleanup()
    {
    if (m_pMenu)
    {
    delete m_pMenu;
    }
    m_pMenu = NULL;
    m_nMenuId = (UINT)-1;
    m_nSubMenuId = (UINT)-1;
    }

    and the m_pMenu pointer is always initialized and while the line

    delete m_pMenu;

    get executed all the application ruining fails. Please help me solve the case, what should I do?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups