로그인

검색

MoA
조회 수 3996 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 게시글 수정 내역 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 게시글 수정 내역 댓글로 가기 인쇄

http://support.microsoft.com/kb/242577 참고


1. ON_WM_INITMENUPOPUP 메시지 추가


BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
//}}AFX_MSG_MAP

ON_WM_INITMENUPOPUP()
END_MESSAGE_MAP()

2. OnInitMenuPopup 멤버 함수를 대화 상자 클래스에 추가 하 고 다음 코드 복사


void CTestDlg::OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu)
{
    ASSERT(pPopupMenu != NULL);
    // Check the enabled state of various menu items.

    CCmdUI state;
    state.m_pMenu = pPopupMenu;
    ASSERT(state.m_pOther == NULL);
    ASSERT(state.m_pParentMenu == NULL);

    // Determine if menu is popup in top-level menu and set m_pOther to
    // it if so (m_pParentMenu == NULL indicates that it is secondary popup).
    HMENU hParentMenu;
    if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu)
        state.m_pParentMenu = pPopupMenu;    // Parent == child for tracking popup.
    else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
    {
        CWnd* pParent = this;
           // Child windows don't have menus--need to go to the top!
        if (pParent != NULL &&
           (hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
        {
           int nIndexMax = ::GetMenuItemCount(hParentMenu);
           for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
           {
            if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu)
            {
                // When popup is found, m_pParentMenu is containing menu.
                state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
                break;
            }
           }
        }
    }

    state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
    for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
      state.m_nIndex++)
    {
        state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
        if (state.m_nID == 0)
           continue; // Menu separator or invalid cmd - ignore it.

        ASSERT(state.m_pOther == NULL);
        ASSERT(state.m_pMenu != NULL);
        if (state.m_nID == (UINT)-1)
        {
           // Possibly a popup menu, route to first item of that popup.
           state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
           if (state.m_pSubMenu == NULL ||
            (state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
            state.m_nID == (UINT)-1)
           {
            continue;       // First item of popup can't be routed to.
           }
           state.DoUpdate(this, TRUE);   // Popups are never auto disabled.
        }
        else
        {
           // Normal menu item.
           // Auto enable/disable if frame window has m_bAutoMenuEnable
           // set and command is _not_ a system command.
           state.m_pSubMenu = NULL;
           state.DoUpdate(this, FALSE);
        }

        // Adjust for menu deletions and additions.
        UINT nCount = pPopupMenu->GetMenuItemCount();
        if (nCount < state.m_nIndexMax)
        {
           state.m_nIndex -= (state.m_nIndexMax - nCount);
           while (state.m_nIndex < nCount &&
            pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
           {
            state.m_nIndex++;
           }
        }
        state.m_nIndexMax = nCount;
    }
}


?

  1. Programming 게시판 관련

    Date2014.11.01 CategoryTool/etc ByMoA Views15452
    read more
  2. What does set -e mean in a bash script?

    Date2021.04.29 CategoryTool/etc ByOBG Views3360
    Read More
  3. What does the last “-” (hyphen) mean in options of `bash`?

    Date2021.04.29 CategoryTool/etc ByOBG Views2795
    Read More
  4. What to use instead of “addPreferencesFromResource” in a PreferenceActivity?

    Date2013.06.13 CategoryJAVA/Android ByMoA Views2976
    Read More
  5. What's the difference between comma separated joins and join on syntax in MySQL?

    Date2022.06.09 CategoryDatabase ByOBG Views2776
    Read More
  6. Which Font is the default for MFC Dialog Controls

    Date2013.06.12 CategoryAPI/MFC ByMoA Views3335
    Read More
  7. Win32 Socket Class

    Date2012.08.02 CategoryLibrary ByNaya Views3585
    Read More
  8. Windows 10 앱 개발(UWP)

    Date2015.10.13 CategoryAPI/MFC ByMoA Views3380
    Read More
  9. WTL 정리

    Date2013.12.22 CategoryAPI/MFC ByMoA Views3576
    Read More
  10. XML 파싱하기

    Date2013.08.06 CategoryJAVA/Android ByMoA Views8943
    Read More
  11. 강화학습 학습 관련 정리

    Date2022.08.10 CategoryDeeplearning ByOBG Views2845
    Read More
  12. 개발에 도움되는 사이트 (초보 개발자 꿀팁)

    Date2023.01.28 CategorySite ByOBG Views2490
    Read More
  13. 개발자를 위한 각 기업 오픈소스 공유 사이트 (주로 모바일)

    Date2012.08.02 CategorySite ByNaya Views3686
    Read More
  14. 검색엔진 개발자 그룹

    Date2013.08.30 CategorySite ByMoA Views2756
    Read More
  15. 고수가 절대 알려주지 않는 C/C++ 팁

    Date2011.09.23 CategoryC/C++ By너울 Views2972
    Read More
  16. 고양이 밖으로 못나가게 하기

    Date2013.11.10 CategoryPython ByMoA Views3416
    Read More
  17. 고양이 움직이기

    Date2013.11.08 CategoryPython ByMoA Views3438
    Read More
  18. 구글 검색 알고리즘의 원리

    Date2012.08.02 CategoryAlgorithm ByNaya Views3306
    Read More
  19. 나이 들어가는 프로그래머 - [발표영상] 요약

    Date2025.02.14 CategoryTool/etc ByOBG Views2007
    Read More
  20. 내 마음대로 선정한 머신러닝/딥러닝 학습 추천 서적

    Date2023.08.14 CategoryDeeplearning ByOBG Views2908
    Read More
  21. 다국어를 위한 StringTable, LoadString

    Date2013.12.22 CategoryAPI/MFC ByMoA Views4880
    Read More
Board Pagination Prev 1 ... 6 7 8 9 10 11 12 13 14 15 Next
/ 15