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
J

joliet

@joliet
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • CMFCToolBarComboBoxButton::GetByCmd returns NULL
    J joliet

    I created a CMFCToolBarComboBoxButton in a CMFCToolBar as following:

    afx_msg LRESULT CMainFrame::OnToolbarReset(WPARAM wp, LPARAM lp)
    {
    UINT uiToolBarId = (UINT) wp;
    if (uiToolBarId == IDR_TOOLBAR_FILES)
    {
    CMFCToolBarComboBoxButton omboButton1(IDC_SRC_PRO_LIST, GetCmdMgr ()->GetCmdImage(IDC_SRC_PRO_LIST, FALSE), CBS_DROPDOWNLIST);

        comboButton1.EnableWindow(FALSE);
        comboButton1.SetCenterVert();
        comboButton1.SetDropDownHeight(200);
        comboButton1.SetFlatMode();
        m\_wndFilesBar.ReplaceButton (IDC\_SRC\_PRO\_LIST, comboButton1);
     }
    

    }

    It runs well. But when I want to add some content into it from another thread.I defined a function:

    int CMainFrame::CBAddItem(LPCTSTR lpszItem, DWORD_PTR dwData)
    {
    int r = -1;
    CMFCToolBarComboBoxButton* pSrcCombo = CMFCToolBarComboBoxButton::GetByCmd (IDC_SRC_PRO_LIST);
    if(pSrcCombo)
    {
    r = pSrcCombo->AddItem(lpszItem, dwData);
    }
    return r;
    }

    The function CMFCToolBarComboBoxButton::GetByCmd always return NULL. And I traced this function, found:

    int __stdcall CMFCToolBar::GetCommandButtons(UINT uiCmd, CObList& listButtons)
    {
    .....
    for (POSITION posTlb = afxAllToolBars.GetHeadPosition(); posTlb != NULL;)
    {
    CMFCToolBar* pToolBar = (CMFCToolBar*) afxAllToolBars.GetNext(posTlb);
    ENSURE(pToolBar != NULL);

        if (CWnd::FromHandlePermanent(pToolBar->m\_hWnd) != NULL)
    

    CWnd::FromHandlePermanent(pToolBar->m_hWnd) always return NULL. So why?

    C / C++ / MFC
  • Login

  • Don't have an account? Register

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