로그인

검색

MoA
조회 수 5744 추천 수 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;
    }
}


?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 Tool/etc Programming 게시판 관련 2 MoA 2014.11.01 24367
327 API/MFC 후킹 링크 MoA 2013.07.28 5558
326 Python 화면 캡쳐 소스 MoA 2014.01.14 4989
325 API/MFC 프린터 출력하기 MoA 2013.10.16 8221
324 API/MFC 프로세스 - 생성과 종료 그리고 이것 저것 너울 2011.10.12 5463
323 API/MFC 프로그램 배포용으로 만드는 과정 너울 2012.01.20 5093
322 Site 프로그래밍 관련 사이트 MoA 2012.08.02 4265
321 C/C++ 파일 입출력 MoA 2013.07.28 3885
320 Python 파이썬에서 C모듈 사용하기 MoA 2014.02.10 5655
319 Deeplearning 파이썬 머신러닝 무료 강의 (7시간) OBG 2022.07.06 8180
318 Site 특정 자료형의 데이터를 binary(hex값, 2진수값)으로 변환 Naya 2012.11.15 4987
317 Tool/etc 텍스트 에디터 Sublime Text 2 너울 2012.03.30 4895
316 API/MFC 태스크 대화상자 (Task Dialog) MoA 2013.10.22 5028
315 Algorithm 큰 수 구하기 알고리즘 Naya 2012.08.02 4583
314 Tool/etc 쿠버네티스 클러스터 OBG 2022.11.11 4521
313 Agent 코딩 에이전트 만드는 법 OBG 2025.08.28 1870
312 C/C++ 코드 실행 시간 계산 Naya 2012.08.02 4658
311 C/C++ 코드 실행 시간 계산 Naya 2012.09.27 4071
310 Tool/etc 컨텍스트 스위칭 (Context Switching) MoA 2013.07.28 5129
309 Web 카카오톡 웹버전 만들기 OBG 2022.11.09 4104
308 Deeplearning 추천(Recommendation) 시스템 - 알고리즘 Trend 정리 OBG 2021.08.03 4307
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 17 Next
/ 17