Пример #1
0
void	CToolBarPropertyPage::_AddCommandtoListFromSubMenu(CMenuHandle subMenu)
{
	int nAddCnt = 0;
	int nPopStartIndex = m_listCommand.AddString(g_cSeparater);

	for (int i = 0; i < subMenu.GetMenuItemCount(); ++i) {
		HMENU hMenuSub = subMenu.GetSubMenu(i);
		if (hMenuSub) {
			_AddCommandtoListFromSubMenu(hMenuSub);
		}

		UINT nCmdID = subMenu.GetMenuItemID(i);
		if ( _DontUseID(nCmdID) ) break;

		CString strMenu;
		CToolTipManager::LoadToolTipText(nCmdID, strMenu);
		if ( strMenu.IsEmpty() ) continue;

		int nIndex = m_listCommand.AddString(strMenu);
		m_listCommand.SetItemData(nIndex, nCmdID);
		nAddCnt++;
	}

	if (nAddCnt != 0) {
		m_listCommand.AddString(g_cSeparater);
	} else {
		m_listCommand.GetItemData(nPopStartIndex);
		m_listCommand.DeleteString(nPopStartIndex);
	}
	
}
Пример #2
0
LRESULT formview::OnContextMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
{
    CMenu formviewmenu;
    const POINT point = {LOWORD(lParam), HIWORD(lParam)};
    formviewmenu.LoadMenuA(IDR_LISTVIEWMENU);

    {
        LVITEMA item;
        CMenuHandle listviewmenu = formviewmenu.GetSubMenu(1);
        if(this->listview_m.GetSelectedItem(&item))
        {
            listviewmenu.SetMenuDefaultItem(ID_POPUP_OPEN);
            listviewmenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, *this);
            return 0;
        }
    }
    {
        CRect rect;
        this->listview_m.GetWindowRect(&rect);
        CMenuHandle listviewmenu = formviewmenu.GetSubMenu(0);
        if(rect.PtInRect(point))
            listviewmenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, *this);
    }

    return 0;
}
Пример #3
0
// 增加窗口弹出的代码开始
///////////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CFloatingWnd::OnInitMenuPopup(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled)
{
	int nPos;
	UINT uId;
	// Call CCoolContextMenu's implementation
	CCoolContextMenu<CFloatingWnd>::OnInitMenuPopup(uMsg, wParam, lParam, bHandled);
	// Set the cursor shape to an arrow
	m_hCursor = ::LoadCursor(NULL, IDC_ARROW);
	ATLASSERT(m_hCursor);
	::SetCursor(m_hCursor);
	CMenuHandle menuPopup = (HMENU)wParam;
	ATLASSERT(menuPopup.m_hMenu != NULL);
	for (nPos = 0; nPos < menuPopup.GetMenuItemCount(); nPos++)
	{ 
		uId = GetMenuItemID(menuPopup, nPos);
		switch (uId) 
		{ 
		case ID_EDIT_SELECT_ALL:
			EnableMenuItem(menuPopup, uId, (GetWindowTextLength() > 0) ? MF_BYCOMMAND | MF_ENABLED : MF_BYCOMMAND | MF_GRAYED);
			break;
		case ID_EDIT_CUT: 
		case ID_EDIT_COPY: 
		case ID_EDIT_PASTE: 
			EnableMenuItem(menuPopup, uId, IsClipboardFormatAvailable(CF_TEXT) ? MF_BYCOMMAND | MF_ENABLED : MF_BYCOMMAND | MF_GRAYED);
			break;
		default:
			break;
		}
	}
	return 0;
}
Пример #4
0
LRESULT CMainFrame::OnToolBarDropDown(LPNMHDR lpNMHDR)
{
	NMTOOLBAR* pnmtb = reinterpret_cast<NMTOOLBAR*>(lpNMHDR);
	switch(pnmtb->iItem)
	{
	case IDM_TOOL_MIRROR:
		{
			// Display dropdown menu
			CMenu menu;
			CMenuHandle subMenu;
			CRect rect;
			m_wndToolBar.GetRect( pnmtb->iItem, rect );
			m_wndToolBar.ClientToScreen( rect );
			menu.LoadMenu( MAKEINTRESOURCE(IDR_MIRROR_MENU) );
			subMenu = menu.GetSubMenu(0);
			subMenu.TrackPopupMenu(
				TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_VERTICAL,
				rect.left,
				rect.bottom,
				m_hWnd
				);
		}
	default:
		break;
	}
	
	return 0;
}
LRESULT CChildFrame::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{ 
    uMsg, wParam, lParam, bHandled; 

    bHandled = FALSE; 

    POINT ptScr = { 0 }; 

    ptScr.x = GET_X_LPARAM(lParam); 
    ptScr.y = GET_Y_LPARAM(lParam); 

    { 
        POINT ptLoc = ptScr; 

        DWORD dwStyle = m_wndCatalog.GetStyle(); 
        if(WS_VISIBLE != (dwStyle & WS_VISIBLE)) 
            return S_OK; 

        RECT rc; 
        m_wndCatalog.GetClientRect(&rc); 

        // 将屏幕坐标转换成指定窗口的相对坐标 
        m_wndCatalog.ScreenToClient(&ptLoc); 

        // 鼠标指针是否在 TreeView 窗口内 
        if (::PtInRect(&rc, ptLoc)) 
        { 
            UINT flags = 0;
            m_pData = m_wndCatalog.HitTest(ptLoc, &flags); 

            if (FALSE == m_pData.IsNull()) 
            { 
				TREE_ITEM_DATA * pTmp = (TREE_ITEM_DATA *)m_pData.GetData();

                CMenuHandle mnuPopUp; 
                CMenu mnuTemp; 
                
                mnuTemp.LoadMenu(IDR_MENU_EXPORT); 
                mnuPopUp = mnuTemp.GetSubMenu(0); 
				if (pTmp->dwStgType == STGTY_STORAGE)
				{
					mnuPopUp.EnableMenuItem(ID_FILE_ADD_STG, MF_BYCOMMAND|MF_ENABLED);
					mnuPopUp.EnableMenuItem(ID_FILE_ADD_STM, MF_BYCOMMAND|MF_ENABLED);
				}

                mnuPopUp.TrackPopupMenu(0, ptScr.x, ptScr.y, *this); 
                return 0; 
            } 
        } 
    } 

    return 0; 
} 
Пример #6
0
LRESULT CVGMFileListView::OnContextMenu(HWND hwndCtrl, CPoint ptClick )
{
	//bHandled = TRUE;
	//CTreeViewCtrlEx* treeview = (CTreeViewCtrlEx*)hwndCtrl;

	// if Shift-F10
	if (ptClick.x == -1 && ptClick.y == -1)
		ptClick = (CPoint) GetMessagePos();

	ScreenToClient(&ptClick);

	UINT uFlags;
	//HTREEITEM htItem = GetTreeCtrl().HitTest( ptMousePos, &uFlags );
	int iItem = HitTest( ptClick, &uFlags );

	if( iItem == -1 )
		return 0;

	vector<VGMFile*> vgmfiles;
	UINT selectedCount = GetSelectedCount();
	if (selectedCount > 1)
	{
		iItem = -1;
		for (UINT i = 0; i < selectedCount; i++)
		{
			iItem = GetNextItem(iItem, LVNI_SELECTED);
			ATLASSERT(iItem != -1);
			vgmfiles.push_back((VGMFile*)GetItemData(iItem));
		}
	}
	else
	{
		vgmfiles.push_back((VGMFile*)GetItemData(iItem));
	}

	if (vgmfiles.size() > 1)
	{
		CMenu mnuContext;
		mnuContext.LoadMenu(IDR_RAWFILE);
		CMenuHandle pPopup = mnuContext.GetSubMenu(0);
		ClientToScreen(&ptClick);
		pPopup.TrackPopupMenu( TPM_LEFTALIGN, ptClick.x, ptClick.y, hwndCtrl );
	}
	else
	{
		VGMFile* pvgmfile = vgmfiles[0];
		ClientToScreen(&ptClick);
		ItemContextMenu(hwndCtrl, ptClick, pvgmfile);
	}

	return NULL;
}
Пример #7
0
void CMainFrame::OnContextMenu(HWND /*hWnd*/, CPoint pos)
{
	int selectedItemData;

	// get selectedItemData
	CRect rect;
	CPoint posInView;
	HTREEITEM hItemSelected;

	// if clicked on tree, we need to change selection
	if (m_viewTreeList.GetWindowRect( rect ) && rect.PtInRect(pos) )
	{
		CTreeViewCtrlEx ctrlTree = m_viewTreeList.GetTreeControl();
		CHeaderCtrl ctrlHeader = m_viewTreeList.GetHeaderControl();

		CRect rectHeader;
		ctrlHeader.GetClientRect(rectHeader);

		// clicked point is inside the tree control
		// Change screen coordinates to client coordinates
		posInView = pos - rect.TopLeft();
		posInView.y -= rectHeader.Height();

		if(hItemSelected = ctrlTree.HitTest(posInView, NULL))
		{
			ctrlTree.SelectItem(hItemSelected);
		}
	}

	CNBDevice *pDevice = m_viewTreeList.GetSelectedDevice();

	if(!pDevice)
		return;

	CMenu menu;
	CMenuHandle subMenu;

	menu.LoadMenu(IDR_MAINFRAME);
	subMenu = menu.GetSubMenu(1); // Tool
	
	subMenu.TrackPopupMenu(
		TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
		pos.x, 
		pos.y, 
		m_hWnd
		);
	
	return;

}
Пример #8
0
// Creates a context menu
LRESULT CSearchList::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	// Retrieve the index of the currently selected item
	int nIndex = GetSelectedIndex();

	// Display the context menu
	if (nIndex != LB_ERR)
	{
		if (::IsMenu(m_menuSearch.m_hMenu))
		{
			ATLTRACE(_T("Menu is already displayed!\n"));
			return 0;
		}

		// Cursor's horizontal and vertical position
		CPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));

		// Load the menu resource 
		if (!m_menuSearch.LoadMenu(IDR_DELETE_NOTE))
		{
			ATLTRACE(_T("Menu resource was not loaded successfully!\n"));
			return 0;
		}

		// TrackPopupMenu cannot display the menu bar so get 
		// a handle to the first shortcut menu. 
 		CMenuHandle menuPopup = m_menuSearch.GetSubMenu(0);
		if (menuPopup.m_hMenu == NULL)
		{
			ATLTRACE(_T("Submenu was not retrieved successfully!\n"));
			return 0;
		}

		// Display the shortcut menu
 		if (!menuPopup.TrackPopupMenu(TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON,
								pt.x, pt.y, m_hWnd))
		{
			ATLTRACE(_T("Context menu was not displayed successfully!\n"));
			return 0;
		}		

		// Destroy the menu and free any memory that the menu occupies
		menuPopup.DestroyMenu();
		m_menuSearch.DestroyMenu();
		m_menuSearch.m_hMenu = NULL;
	}

	return 0;
}
Пример #9
0
void MainFrame::SetupMRUList()
{
   CMenuHandle menu = m_CmdBar.GetMenu();
   CMenuHandle fileMenu = menu.GetSubMenu(FILE_MENU_POSITION);

#ifdef _DEBUG
   CString cszMenuString;
   fileMenu.GetMenuString(RECENT_MENU_POSITION, cszMenuString, MF_BYPOSITION);

   // when this asserts, RECENT_MENU_POSITION isn't correct anymore
   ATLASSERT(cszMenuString.CompareNoCase(_T("Recent &Files")) == 0);
#endif

   CMenuHandle mruMenu = fileMenu.GetSubMenu(RECENT_MENU_POSITION);
   m_mru.SetMenuHandle(mruMenu);

   m_mru.ReadFromRegistry(c_pszSettingsRegkey);
}
Пример #10
0
LRESULT CMainDlg::OnbtnSetting(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	CRect rect;
	CMenu menu;
	if (IDR_MENU1 == 0)
		return 0;
	if (m_setting.GetCheck() == FALSE)
		m_setting.SetCheck(TRUE);
	m_setting.GetWindowRect(&rect);
	if (!menu.LoadMenu(IDR_MENU1))
		return 0;
	CMenuHandle menuPopup = menu.GetSubMenu(0);
	if (menuPopup == NULL)
		return 0;
	bool rs = menuPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.left, rect.bottom, m_hWnd);
	m_setting.SetCheck(FALSE);
	return 0;
}
Пример #11
0
bool
CUpgradrToolbar::OnDisableDropdown(LPNMTOOLBAR data)
{
	RECT rect;
	m_kToolbar.SendMessage(TB_GETRECT, data->iItem, reinterpret_cast<LPARAM>(&rect));
	m_kToolbar.MapWindowPoints(HWND_DESKTOP, reinterpret_cast<LPPOINT>(&rect), 2);
	TPMPARAMS tpm;
	tpm.cbSize = sizeof(tpm);
	tpm.rcExclude = rect;

	CMenu menu;
	menu.LoadMenu(MAKEINTRESOURCE(IDR_DISABLEMENU));
	if (menu.IsNull()) throw CUpgradrWindowsError(GetLastError());

	ScriptManagerLock scriptManager;
	MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
	UINT pos = 0;
	UINT uID = 1000;

	CMenuHandle popupMenu = menu.GetSubMenu(0);
	if (popupMenu.IsNull()) throw CUpgradrWindowsError(GetLastError());

	CScriptManager::iterator i = scriptManager->begin();
	while (i!=scriptManager->end())
	{
		CScript* script = i->second;

		memset(&mii, 0, sizeof(MENUITEMINFO)); 
		mii.cbSize = sizeof(MENUITEMINFO);
		mii.fMask = MIIM_STATE | MIIM_STRING | MIIM_ID | MIIM_DATA;
		mii.wID = uID++;
		mii.fState = MFS_CHECKED;
		mii.dwItemData = i->first;
		TCHAR buf[1024];
		_tcscpy_s(buf, 1024, script->Name());
		mii.dwTypeData = buf;
		InsertMenuItem(popupMenu, pos++, TRUE, &mii);

		++i;
	}

	TrackPopupMenuEx(popupMenu, TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL, rect.left, rect.bottom, m_kToolbar, &tpm);
	return true;
}
Пример #12
0
LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	// create command bar window
	HWND hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);
	// attach menu
	m_CmdBar.AttachMenu(GetMenu());
	// load command bar images
	m_CmdBar.LoadImages(IDR_MAINFRAME);
	// remove old menu
	SetMenu(NULL);

	HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);

    RECT rect = {0, 0, 30, 30};


	m_edtAddress.Create(this, MAINFRAME_ADDRESS_MSGID, m_hWnd, rect, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

	CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);
	AddSimpleReBarBand(hWndCmdBar);
	AddSimpleReBarBand(hWndToolBar, NULL, TRUE);
	AddSimpleReBarBand(m_edtAddress, NULL, TRUE);

	CreateSimpleStatusBar();

	m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);

	UIAddToolBar(hWndToolBar);
	UISetCheck(ID_VIEW_TOOLBAR, 1);
	UISetCheck(ID_VIEW_STATUS_BAR, 1);

	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	CMenuHandle menuMain = m_CmdBar.GetMenu();
	m_view.SetWindowMenu(menuMain.GetSubMenu(WINDOW_MENU_POSITION));

	return 0;
}
Пример #13
0
bool
CXRefreshToolbar::OnGeneralDropdown(LPNMTOOLBAR data)
{
	RECT rect;
	m_Toolbar.SendMessage(TB_GETRECT, data->iItem, reinterpret_cast<LPARAM>(&rect));
	m_Toolbar.MapWindowPoints(HWND_DESKTOP, reinterpret_cast<LPPOINT>(&rect), 2);
	TPMPARAMS tpm;
	tpm.cbSize = sizeof(tpm);
	tpm.rcExclude = rect;

	CMenu menu;
	menu.LoadMenu(MAKEINTRESOURCE(IDR_TOOLMENU));
	if (menu.IsNull()) throw CXRefreshWindowsError(GetLastError());

	CMenuHandle popupMenu = menu.GetSubMenu(0);
	if (popupMenu.IsNull()) throw CXRefreshWindowsError(GetLastError());

	TrackPopupMenuEx(popupMenu, TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL, rect.left, rect.bottom, m_Toolbar, &tpm);
	return true;
}
Пример #14
0
LRESULT CTrayNotifyIcon::OnTrayNotification(WPARAM wID, LPARAM lEvent)
{
    //Return quickly if its not for this tray icon
    if (wID != m_NotifyIconData.uID)
        return 0L;

#ifdef _AFX
    CMenu* pSubMenu = m_Menu.GetSubMenu(0);
    ATLASSERT(pSubMenu); //Your menu resource has been designed incorrectly
#else
    CMenuHandle subMenu = m_Menu.GetSubMenu(0);
    ATLASSERT(subMenu.IsMenu());
#endif

    //if (lEvent == WM_RBUTTONUP) //TODO on both events?
    if (lEvent == WM_RBUTTONUP || lEvent == WM_LBUTTONDBLCLK)//TODO on both events for version without UI and open
    {
        CPoint ptCursor;
        GetCursorPos(&ptCursor);
        ::SetForegroundWindow(m_NotifyIconData.hWnd);
#ifdef _AFX
        ::TrackPopupMenu(pSubMenu->m_hMenu, TPM_LEFTBUTTON, ptCursor.x, ptCursor.y, 0, m_NotifyIconData.hWnd, NULL);
#else
        ::TrackPopupMenu(subMenu, TPM_LEFTBUTTON, ptCursor.x, ptCursor.y, 0, m_NotifyIconData.hWnd, NULL);
#endif
        ::PostMessage(m_NotifyIconData.hWnd, WM_NULL, 0, 0);
    }
    else if (lEvent == WM_LBUTTONDBLCLK) //double click received, the default action is to execute first menu item
    {
        ::SetForegroundWindow(m_NotifyIconData.hWnd);
#ifdef _AFX
        UINT nDefaultItem = pSubMenu->GetDefaultItem(GMDI_GOINTOPOPUPS, FALSE);
#else
        UINT nDefaultItem = subMenu.GetMenuDefaultItem(FALSE, GMDI_GOINTOPOPUPS);
#endif
        if (nDefaultItem != -1)
            ::SendMessage(m_NotifyIconData.hWnd, WM_COMMAND, nDefaultItem, 0);
    }

    return 1; // handled
}
Пример #15
0
void CDialogConf::OnInitMenuPopup(CMenuHandle menuPopup, UINT nIndex, BOOL bSysMenu)
{
	if (bSysMenu)
	{
		if (!IsMenuItemExist(menuPopup, IDM_ALWAYS_ON_TOP))
		{
			//menuPopup.InsertMenu(SC_MINIMIZE, MF_BYCOMMAND);
			menuPopup.InsertMenu(SC_MINIMIZE, MF_BYCOMMAND, IDM_ALWAYS_ON_TOP, L"Always on top");
			//menuPopup.InsertMenu(SC_MINIMIZE, MF_BYCOMMAND);
		}
		
		if (GetWindowLongPtr(GWL_EXSTYLE) & WS_EX_TOPMOST)
		{
			menuPopup.CheckMenuItem(IDM_ALWAYS_ON_TOP, MF_BYCOMMAND | MF_CHECKED);
		}
		else
		{
			menuPopup.CheckMenuItem(IDM_ALWAYS_ON_TOP, MF_BYCOMMAND | MF_UNCHECKED);
		}
	}
}
Пример #16
0
LRESULT CClassView::OnNmRclickTree(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
	bHandled = FALSE;
	CPoint pt;
	::GetCursorPos(&pt);
	ScreenToClient(&pt);
	UINT uFlags;
	HTREEITEM item = HitTest(pt, &uFlags);
	if ((item != NULL) && (TVHT_ONITEM & uFlags))
	{
		SelectItem(item);

		CMenu menu;
		menu.LoadMenu(IDR_POPUPMENU);
		CMenuHandle popup = menu.GetSubMenu(0);
	
		ClientToScreen(&pt);
		popup.TrackPopupMenu(TPM_LEFTALIGN ,pt.x,pt.y,m_hWnd);
	}
	return -1;
}
Пример #17
0
void CTrayNotifyIcon::SetDefaultMenuItem(UINT uItem, BOOL fByPos)
{
    m_nDefaultMenuItem = uItem;
    m_bDefaultMenuItemByPos = fByPos;

    //Also update in the live menu if it is present
    if (m_Menu.operator HMENU())
    {
#ifdef _AFX
        CMenu* pSubMenu = m_Menu.GetSubMenu(0);
        ATLASSERT(pSubMenu); //Your menu resource has been designed incorrectly

        pSubMenu->SetDefaultItem(m_nDefaultMenuItem, m_bDefaultMenuItemByPos);
#else
        CMenuHandle subMenu = m_Menu.GetSubMenu(0);
        ATLASSERT(subMenu.IsMenu()); //Your menu resource has been designed incorrectly

        subMenu.SetMenuDefaultItem(m_nDefaultMenuItem, m_bDefaultMenuItemByPos);
#endif
    }
}
Пример #18
0
LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	CreateSimpleToolBar();

	CreateSimpleStatusBar();

	m_hWndClient = m_view.Create(m_hWnd);

	UIAddToolBar(m_hWndToolBar);
	UISetCheck(ID_VIEW_TOOLBAR, 1);
	UISetCheck(ID_VIEW_STATUS_BAR, 1);
	UISetCheck(ID_TOOLS_REPEAT, 1);
	UISetCheck(ID_SPEED_100, 1);
	lastSpeedId=ID_SPEED_100;


	
	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	// Init MRU list
	CMenuHandle mainMenu = GetMenu();
	CMenuHandle fileMenu = mainMenu.GetSubMenu(0);
	CMenuHandle mruMenu = fileMenu.GetSubMenu(9);
	m_mru.SetMenuHandle ( mruMenu );
	m_mru.UpdateMenu();
	m_mru.ReadFromRegistry(APP_SETTINGS_KEY);
	m_mru.SetMaxEntries(4);



	UIEnable ( ID_TOOLS_START, true );
    UIEnable ( ID_TOOLS_STOP, false );

	return 0;
}
Пример #19
0
void 
CDismountDialog::OnClose()
{
	if (WAIT_OBJECT_0 == WaitForSingleObject(m_WorkItemFinished, 0))
	{
		SetMsgHandled(FALSE);
	}
	else
	{
		//
		// At first WM_CLOSE, disable the close menu and icon,
		// and queue the close command at work item completion
		//
		if (!m_closeQueued)
		{
			CMenuHandle sysMenu = GetSystemMenu(FALSE);
			sysMenu.ModifyMenu(SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
		}
		m_closeQueued = TRUE;
		SetMsgHandled(TRUE);
	}
}
Пример #20
0
void CTrayNotifyIcon::SetMenu(HMENU hMenu)
{
    //Validate our parameters
    ATLASSERT(hMenu);

    m_Menu.DestroyMenu();
    m_Menu.Attach(hMenu);

#ifdef _AFX
    CMenu* pSubMenu = m_Menu.GetSubMenu(0);
    ATLASSERT(pSubMenu); //Your menu resource has been designed incorrectly

    //Make the specified menu item the default (bold font)
    pSubMenu->SetDefaultItem(m_nDefaultMenuItem, m_bDefaultMenuItemByPos);
#else
    CMenuHandle subMenu = m_Menu.GetSubMenu(0);
    ATLASSERT(subMenu.IsMenu()); //Your menu resource has been designed incorrectly

    //Make the specified menu item the default (bold font)
    subMenu.SetMenuDefaultItem(m_nDefaultMenuItem, m_bDefaultMenuItemByPos);
#endif
}
Пример #21
0
LRESULT CFloatingWnd::OnRButtonDown(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled){
	if (m_FloatingWndmenu.m_hMenu != NULL)
		return 0;
	SetFocus();
	RECT rc;
	GetClientRect(&rc);
	MapWindowPoints(HWND_DESKTOP, (POINT *)&rc, 2);
	// Cursor's horizontal and vertical position
	CPoint pt(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); 
	// Convert client coordinates to screen coordinates 
	ClientToScreen(&pt);
	// Load the menu resource 
	if (!m_FloatingWndmenu.LoadMenu(IDR_POPUP))
	{
		ATLTRACE(_T("Menu resource was not loaded successfully!\n"));
		return 0;
	}
	// TrackPopupMenu cannot display the menu bar so get 
	// a handle to the first shortcut menu. 
 	CMenuHandle menuPopup = m_FloatingWndmenu.GetSubMenu(0);
	if (menuPopup.m_hMenu == NULL)
	{
		ATLTRACE(_T("Submenu was not retrieved successfully!\n"));
		return 0;
	}
	// Display the shortcut menu
 	//if (!menuPopup.TrackPopupMenu(TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, rc.left ,rc.bottom, m_hWnd))
	if (!menuPopup.TrackPopupMenu(TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x ,pt.y, m_hWnd))
	{
		ATLTRACE(_T("Context menu was not displayed successfully!\n"));
		return 0;
	}
	// Destroy the menu and free any memory that the menu occupies
	menuPopup.DestroyMenu();
	m_FloatingWndmenu.DestroyMenu();
	m_FloatingWndmenu.m_hMenu = NULL;
	return 0;
}
Пример #22
0
BOOL
pSetDeviceStatusMenuItem(HMENU hMenu, UINT nStringID)
{
	BOOL fSuccess;
	CMenuHandle menu = hMenu;
	BOOL fShow = TRUE;
	pGetAppConfigValue(_T("ShowDeviceStatusText"), &fShow);
	if (!fShow) {
		return TRUE;
	}

	CMenuItemInfo mii;
	mii.fMask = MIIM_STATE | MIIM_ID | MIIM_FTYPE | MIIM_DATA;
	mii.wID = 100; // status text
	mii.fState = MFS_DISABLED;
	mii.fType = MFT_OWNERDRAW;
	mii.dwItemData = nStringID;
	// mii.dwTypeData = (LPTSTR)nStringID;// (LPTSTR)(LPCTSTR)strStatus;
	fSuccess = menu.InsertMenuItem(0xFFFF, TRUE, &mii);
	ATLASSERT(fSuccess);

	return fSuccess;
}
Пример #23
0
LRESULT CChildFrame::OnWmMDIActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 
{ 
    LRESULT lReturn = CMDIChildWindowImpl<CChildFrame>::OnMDIActivate(uMsg, wParam, lParam, bHandled); 
    
    if ((m_hWnd == (HWND)lParam) && 
        (NULL != m_pUpdateUI) && 
        TRUE) 
    { 
        CMainFrame * pMainFrame = static_cast<CMainFrame *>(m_pUpdateUI); 
        if (pMainFrame) 
        { 
            // Init MRU list 
            CMenuHandle mainMenu = pMainFrame->m_wndCmdBar.GetMenu(); 
            CMenuHandle fileMenu = mainMenu.GetSubMenu(0); 
            
            pMainFrame->m_mru.SetMenuHandle ( fileMenu ); 
            pMainFrame->m_mru.ReadFromRegistry( APP_SETTINGS_KEY ); 
        } 
    } 
    
    bHandled = FALSE; 
    return lReturn; 
} 
Пример #24
0
void 
CDismountAllDialog::OnClose()
{
	if (m_workItemCount > 0)
	{
		//
		// At first WM_CLOSE, disable the close menu and icon,
		// and queue the close command at work item completion
		//
		if (!m_closeQueued)
		{
			CMenuHandle sysMenu = GetSystemMenu(FALSE);
			sysMenu.ModifyMenu(SC_CLOSE, MF_BYCOMMAND | MF_GRAYED);
		}
		m_closeQueued = TRUE;
		SetMsgHandled(TRUE);
	}
	else
	{
		// If there are no outstanding work items,
		// close the dialog
		SetMsgHandled(FALSE);
	}
}
Пример #25
0
/**
 * @param uNotifyCode - notification code if the message is from a control. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero.
 * @param nID - specifies the identifier of the menu item, control, or accelerator.
 * @param hWndCtl - handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL.
 */
void CRadixMenu::OnClick(UINT /*uNotifyCode*/, int /*nID*/, HWND /*hWndCtl*/)
{
	SetState(TRUE);
	CRect rect;
	GetWindowRect(&rect);
	CMenu menuRadixContext;
	if (! menuRadixContext.LoadMenu(IDR_RADIX_CONTEXT))
		return;
	CMenuHandle menuPopup = menuRadixContext.GetSubMenu(0);
	ATLASSERT(menuPopup != NULL);
	if (menuPopup == NULL)
		return;
	switch (::SendMessage(m_hwndEdit, UM_GETNUMFORMAT, 0, 0))
	{
	case CNumEdit::NF_HEX:
		menuPopup.CheckMenuItem(ID_RADIX_HEX, MF_BYCOMMAND | MF_CHECKED);
		break;
	case CNumEdit::NF_DEC:
		menuPopup.CheckMenuItem(ID_RADIX_DEC, MF_BYCOMMAND | MF_CHECKED);
		break;
	}
	menuPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.left, rect.bottom, m_hwndEdit);
	SetState(FALSE);
}
Пример #26
0
void 
CMainFrame::pUpdateMenuItems()
{
	BOOL fSuccess(FALSE);

	if (!ndas::UpdateDeviceList())
	{
		// warning device list update failed.
	}

	if (!ndas::UpdateLogicalDeviceList())
	{
		// warning logical device list update failed.
	}

	m_taskbarMenu.ClearItemStringData();

	BOOL showText = TRUE;
	pGetAppConfigValue(_T("ShowDeviceStatusText"), &showText);
	m_taskbarMenu.ShowDeviceStatusText(showText);

	CMenuHandle taskBarRootMenu;
	taskBarRootMenu.LoadMenu(IDR_TASKBAR);

	if (pGetAppConfigBOOL(_T("ShowUnmountAll"), FALSE)) 
	{
		ndas::LogicalDeviceConstIterator itr = std::find_if(
			m_NdasLogDevices.begin(),
			m_NdasLogDevices.end(),
			ndas::LogicalDeviceMounted());

		if (m_NdasLogDevices.end() != itr)
		{
			// There is a mounted logical device 
			taskBarRootMenu.EnableMenuItem(
				IDR_UNMOUNT_ALL, 
				MF_BYCOMMAND | MFS_ENABLED);
		}
		else
		{
			// There is no mounted logical device
			taskBarRootMenu.EnableMenuItem(
				IDR_UNMOUNT_ALL, 
				MF_BYCOMMAND | MFS_DISABLED);
		}

		// do not remove menu
	}
	else 
	{
		// otherwise remove menu
		taskBarRootMenu.RemoveMenu(IDR_UNMOUNT_ALL, MF_BYCOMMAND);
	}

	CMenuHandle taskBarMenu = ::GetSubMenu(taskBarRootMenu,0);

	MENUINFO mi = {0};
	mi.cbSize = sizeof(MENUINFO);
	mi.fMask = MIM_STYLE;
	fSuccess = taskBarMenu.GetMenuInfo(&mi);
	ATLASSERT(fSuccess);

	mi.cbSize = sizeof(MENUINFO);
	mi.fMask = MIM_STYLE | MIM_APPLYTOSUBMENUS;
	mi.dwStyle |= MNS_NOTIFYBYPOS | MNS_CHECKORBMP;
	fSuccess = taskBarMenu.SetMenuInfo(&mi);
	ATLASSERT(fSuccess);

	if (m_NdasDevices.empty()) 
	{
		CMenuItemInfo mii;
		CString strMenuText = MAKEINTRESOURCE(IDS_NO_DEVICE);
		mii.fMask = MIIM_ID | MIIM_STRING | MIIM_STATE;
		mii.dwTypeData = (LPTSTR)((LPCTSTR)strMenuText);
		mii.wID = IDR_NDAS_DEVICE_NONE;
		mii.fState = MFS_DISABLED | MFS_UNHILITE;

		fSuccess = taskBarMenu.InsertMenuItem(0, TRUE, &mii);
		ATLASSERT(fSuccess);
	} 
	else 
	{
		std::for_each(
			m_NdasDevices.begin(),
			m_NdasDevices.end(), 
			NdasDeviceMenuItemCreator(m_taskbarMenu, taskBarMenu));
	}

	CMenu existingTaskbarMenu = m_taskbarIcon.m_hMenu;
	m_taskbarIcon.m_hMenu = taskBarRootMenu;
}
Пример #27
0
void
CNdasDeviceMenu::AppendUnitDeviceMenuItem(
	ndas::UnitDevicePtr pUnitDevice,
	HMENU hMenu,
	PBYTE pPartStatus)
{
	CMenuHandle menu = hMenu;
	CMenuItemInfo mii;
	CString strText;
	BOOL fSuccess = FALSE;

	CMenuItemInfo sep;
	sep.fMask = MIIM_TYPE;
	sep.fType = MFT_SEPARATOR;

	mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_STATE;
	mii.fState = MFS_ENABLED;
	mii.dwItemData = 
		((WORD) pUnitDevice->GetSlotNo()) |
		(((WORD) pUnitDevice->GetUnitNo()) << 16);

	NDAS_LOGICALDEVICE_ID logDeviceId = pUnitDevice->GetLogicalDeviceId();
	ndas::LogicalDevicePtr pLogDevice;
	if (!ndas::FindLogicalDevice(pLogDevice, logDeviceId)) 
	{
		pSetDeviceStatusMenuItem(menu, IDS_DEVMST_ERROR);
		if (pUnitDevice->GetStatus() == NDAS_UNITDEVICE_STATUS_ERROR)
		{
			*pPartStatus = NDSI_PART_ERROR;
		}
		return;
	}

	pLogDevice->UpdateStatus();
	pLogDevice->UpdateInfo();

	mii.dwItemData = pLogDevice->GetLogicalDeviceId();

	NDAS_LOGICALDEVICE_STATUS lstatus = pLogDevice->GetStatus();

	if (NDAS_LOGICALDEVICE_STATUS_MOUNTED == lstatus ||
		NDAS_LOGICALDEVICE_STATUS_UNMOUNT_PENDING == lstatus) 
	{

		if (pLogDevice->GetMountedAccess() & GENERIC_WRITE) 
		{
			*pPartStatus = NDSI_PART_MOUNTED_RW;
			pSetDeviceStatusMenuItem(menu, IDS_DEVMST_MOUNTED_RW);
		}
		else 
		{
			*pPartStatus = NDSI_PART_MOUNTED_RO;
			pSetDeviceStatusMenuItem(menu, IDS_DEVMST_MOUNTED_RO);
		}
		if (pLogDevice->IsContentEncrypted())
		{
			*pPartStatus |= NDSI_PART_CONTENT_IS_ENCRYPTED;
		}

		ATLVERIFY(strText.LoadString(IDR_NDD_UNMOUNT));

		mii.wID = IDR_NDD_UNMOUNT;
		mii.dwTypeData = LPTSTR(LPCTSTR(strText));

		if (NDAS_LOGICALDEVICE_STATUS_UNMOUNT_PENDING == lstatus) 
		{
			mii.fState = MFS_DISABLED;
		}

		ATLVERIFY(menu.InsertMenuItem(0xFFFF, TRUE, &mii));
		ATLVERIFY(menu.InsertMenuItem(0xFFFF, TRUE, &sep));

	}
	else if (NDAS_LOGICALDEVICE_STATUS_UNMOUNTED == lstatus ||
		NDAS_LOGICALDEVICE_STATUS_MOUNT_PENDING == lstatus) 
	{
		*pPartStatus = NDSI_PART_UNMOUNTED;
		if (pLogDevice->IsContentEncrypted())
		{
			*pPartStatus |= NDSI_PART_CONTENT_IS_ENCRYPTED;
		}

		pSetDeviceStatusMenuItem(menu, IDS_DEVMST_CONNECTED);

		// push the status
		UINT fSavedState = mii.fState;

		ATLVERIFY(strText.LoadString(IDR_NDD_MOUNT_RO));

		mii.wID = IDR_NDD_MOUNT_RO;
		mii.dwTypeData = LPTSTR(LPCTSTR(strText));
		mii.fState = (pLogDevice->GetGrantedAccess() & GENERIC_READ) ?
			MFS_ENABLED : MFS_DISABLED;

		if (NDAS_LOGICALDEVICE_STATUS_MOUNT_PENDING == lstatus) 
		{
			mii.fState = MFS_DISABLED;
		}

		ATLVERIFY(menu.InsertMenuItem(0xFFFF, TRUE, &mii));

		ATLVERIFY(strText.LoadString(IDR_NDD_MOUNT_RW));

		mii.wID = IDR_NDD_MOUNT_RW;
		mii.dwTypeData = LPTSTR(LPCTSTR(strText));
		mii.fState = (pLogDevice->GetGrantedAccess() & GENERIC_WRITE) ?
			MFS_ENABLED : MFS_DISABLED;

		if (NDAS_LOGICALDEVICE_STATUS_MOUNT_PENDING == lstatus) 
		{
			mii.fState = MFS_DISABLED;
		}

		ATLVERIFY(menu.InsertMenuItem(0xFFFF, TRUE, &mii));

		// pop the status;
		mii.fState = fSavedState;

		ATLVERIFY(menu.InsertMenuItem(0xFFFF, TRUE, &sep));

	} 
	else if (NDAS_LOGICALDEVICE_STATUS_NOT_INITIALIZED == lstatus) 
	{
		// not used
		*pPartStatus = NDSI_PART_UNMOUNTED;
	}
	else if (NDAS_LOGICALDEVICE_STATUS_UNKNOWN == lstatus) 
	{
		// not used
		*pPartStatus = NDSI_PART_UNMOUNTED;
	}
	else 
	{
		ATLASSERT(FALSE);
	}
}
Пример #28
0
HMENU 
CNdasDeviceMenu::CreateDeviceSubMenu(
	__in ndas::DevicePtr pDevice,
	__out NDSI_DATA* psiData)
{
	CMenuHandle menu;
	CString strText;

	CMenuItemInfo sep;
	sep.fMask = MIIM_TYPE;
	sep.fType = MFT_SEPARATOR;

	CMenuItemInfo mii;
	mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA;
	mii.dwItemData = (WORD)pDevice->GetSlotNo();

	ATLVERIFY(menu.CreateMenu());

	NDAS_DEVICE_STATUS status = pDevice->GetStatus();
	// Enable or Disable

	BOOL fShowUnregister = FALSE;

	if (NDAS_DEVICE_STATUS_DISABLED == status) 
	{
		psiData->Status = NDSI_DISABLED;

		pSetDeviceStatusMenuItem(menu,IDS_DEVMST_DEACTIVATED);

		ATLVERIFY(strText.LoadString(IDS_ACTIVATE_DEVICE));

		mii.wID = IDR_ENABLE_DEVICE;
		mii.dwTypeData = (LPTSTR)(LPCTSTR)strText;

		ATLVERIFY(menu.InsertMenuItem(0xFFFF, TRUE, &mii));

		fShowUnregister = TRUE;

	} 
	else if (NDAS_DEVICE_STATUS_DISCONNECTED == status) 
	{
		//
		// although there is no ERROR status in NDAS device,
		// if the last error is set, we will show the indicator
		// as error
		//
		psiData->Status = 
			(ERROR_SUCCESS == pDevice->GetLastError()) ? 
			NDSI_DISCONNECTED : 
			NDSI_ERROR;

		ATLVERIFY(pSetDeviceStatusMenuItem(menu, IDS_DEVMST_DISCONNECTED));
		fShowUnregister = TRUE;
	}
	else if (NDAS_DEVICE_STATUS_UNKNOWN == status) 
	{
		psiData->Status = NDSI_UNKNOWN;
		ATLVERIFY(pSetDeviceStatusMenuItem(menu, IDS_DEVMST_UNKNOWN));
		fShowUnregister = TRUE;
	} 
	else if (NDAS_DEVICE_STATUS_CONNECTING == status)
	{
		psiData->Status = NDSI_CONNECTING;
		ATLVERIFY(pSetDeviceStatusMenuItem(menu, IDS_DEVMST_CONNECTING));
		fShowUnregister = TRUE;
	}
	else if (NDAS_DEVICE_STATUS_CONNECTED == status) 
	{
		psiData->Status = NDSI_CONNECTED;

		BOOL fMounted = FALSE;

		ndas::UnitDeviceVector unitDevices = pDevice->GetUnitDevices();
		int i = 0;
		for (ndas::UnitDeviceConstIterator itr = unitDevices.begin();
			itr != unitDevices.end(); ++itr, ++i)
		{
			ndas::UnitDevicePtr pUnitDevice = *itr;

			pUnitDevice->UpdateStatus();

			BYTE bReserved;
			psiData->nParts = min(i + 1, 2);
			AppendUnitDeviceMenuItem(
				pUnitDevice, 
				menu.m_hMenu, 
				(i < 2) ? &psiData->StatusPart[i] : &bReserved);

			// If there is a mounted unit device, DISABLE menu will be disabled.
			if (NDAS_UNITDEVICE_STATUS_MOUNTED == pUnitDevice->GetStatus()) 
			{
				fMounted = TRUE;
			}
		}

		if (!fMounted) 
		{
			fShowUnregister = TRUE;
		}
	}

	//
	// Unregister Device Menu
	//
	if (fShowUnregister) 
	{
		ATLVERIFY(strText.LoadString(IDS_UNREGISTER_DEVICE));
		mii.wID = IDR_UNREGISTER_DEVICE;
		mii.dwTypeData = (LPTSTR)(LPCTSTR)strText;
		ATLVERIFY(menu.InsertMenuItem(0xFFFF, TRUE, &mii));
		ATLVERIFY(menu.InsertMenuItem(0xFFFF, TRUE, &sep));
	}

	ATLVERIFY(strText.LoadString(IDS_SHOW_DEVICE_PROPERTIES));
	mii.wID = IDR_SHOW_DEVICE_PROPERTIES;
	mii.dwTypeData = (LPTSTR)(LPCTSTR)strText;
	ATLVERIFY(menu.InsertMenuItem(0xFFFF, TRUE, &mii));

	return menu.m_hMenu;
}
Пример #29
0
LRESULT CServerListView::OnContextMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
{
  RECT rc;
  UINT Flags;
  HTREEITEM hItem;
  TreeItemInfo *pTII = NULL;
  IRCChannel *pChannel = NULL;
  IRCServer *pServer = NULL;

	POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };

  // mouse click location

	m_tree.GetClientRect(&rc);
	m_tree.ScreenToClient(&pt); 

  hItem = m_tree.HitTest(pt,&Flags);

  if (hItem != NULL)
  {
    TVITEM item;
    item.mask = TVIF_PARAM;
	  item.lParam = 0;  
    item.hItem = hItem; // we want more info about this tree node.
    if (m_tree.GetItem(&item))
    {
      pTII = (TreeItemInfo *)item.lParam;
      m_SelectedTreeItem = pTII;
      switch (pTII->m_Type)
      {
        case TII_IRCCHANNEL:
          // add channel context menu items
          pChannel = (IRCChannel *)pTII->m_Data;
          break;
        case TII_IRCSERVER:
          // add server context menu items
          pServer = (IRCServer *)pTII->m_Data;
          break;
      }
    }
  }

  // build the menu.

  if (pTII)
  {
    // only show context menus for these tree items...
    if (pTII->m_Type == TII_IRCCHANNEL || pTII->m_Type == TII_IRCSERVER ||
        pTII->m_Type == TII_QUERY || pTII->m_Type == TII_DCCCHAT)
    {
      CMenuHandle Menu;
      Menu.CreatePopupMenu();

      switch(pTII->m_Type)
      {
        case TII_IRCSERVER:
          if (pServer)
          {
            if (pServer->GetStatus() == SVR_STATE_DISCONNECTED)
              Menu.AppendMenu(MF_STRING,SLMI_Connect,   _T("&Connect"));

            if (pServer->GetStatus() == SVR_STATE_CONNECTED)
            {
              Menu.AppendMenu(MF_STRING,SLMI_Reconnect, _T("&Reconnect"));
              Menu.AppendMenu(MF_STRING,SLMI_Disconnect,_T("&Disconnect"));
              Menu.AppendMenu(MF_STRING,SLMI_ListChannels,_T("Channel &List"));
            }
          }
          break;
      }

      if (pTII->m_Type == TII_IRCCHANNEL || pTII->m_Type == TII_IRCSERVER ||
          pTII->m_Type == TII_QUERY || pTII->m_Type == TII_DCCCHAT)
      {
        Menu.AppendMenu(MF_STRING,SLMI_Logging,_T("Lo&gging"));
      }

      if (pTII->m_Type == TII_IRCCHANNEL || pTII->m_Type == TII_IRCSERVER)
      {
        Menu.AppendMenu(MF_STRING,SLMI_Monitoring,_T("&Monitoring"));
      }

      switch(pTII->m_Type)
      {
        case TII_IRCCHANNEL:
          if (pChannel)
          {
            Menu.AppendMenu(MF_STRING,SLMI_Cycle,     _T("C&ycle"));
            Menu.AppendMenu(MF_STRING,SLMI_Properties,_T("&Properties"));
          }
          break;
      }

      Menu.AppendMenu(MF_STRING,SLMI_Close,_T("C&lose"));


      ::GetCursorPos(&pt);      
      g_pMainWnd->m_CmdBar.TrackPopupMenu(Menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y);
      //::TrackPopupMenu(Menu, 0, pt.x, pt.y, 0, m_hWnd, NULL);
    }
  }

  return 0; // WM_CONTEXTMENU - No return value
}
Пример #30
0
//---------------------------------
/// nIndexはカテゴリコンボボボックスの現在選択されているセル
/// コマンドリストにカテゴリで選択されたメニューを登録する
void	CToolBarPropertyPage::_SetCommandList(int nIndex)
{
	m_listCommand.ResetContent();

	if (nIndex + 1 == m_cmbCategory.GetCount()) {
		// ドロップダウン・アイコンのとき
		for (int ii = 0; ii < g_uDropDownCommandCount; ii++) {
			CString strMenu;
			strMenu.LoadString(g_uDropDownCommandID[ii]);

			if (strMenu.Find(_T("\n")) != -1)
				strMenu = strMenu.Left( strMenu.Find(_T("\n")) );

			int 	nIndex = m_listCommand.AddString(strMenu);
			m_listCommand.SetItemData(nIndex, g_uDropDownCommandID[ii]);
		}

		for (int ii = 0; ii < g_uDropDownWholeCommandCount; ii++) {
			CString strMenu;
			strMenu.LoadString(g_uDropDownWholeCommandID[ii]);

			if (strMenu.Find(_T("\n")) != -1)
				strMenu = strMenu.Left( strMenu.Find(_T("\n")) );

			int 	nIndex = m_listCommand.AddString(strMenu);
			m_listCommand.SetItemData(nIndex, g_uDropDownWholeCommandID[ii]);
		}
	} else {
		CMenuHandle	subMenu = ::GetSubMenu(m_hMenu, nIndex);
		for (int i = 0; i < subMenu.GetMenuItemCount(); ++i) {
			HMENU hMenuSub = subMenu.GetSubMenu(i);
			if (hMenuSub) {
				_AddCommandtoListFromSubMenu(hMenuSub);
			}

			UINT nCmdID = subMenu.GetMenuItemID(i);
			if ( _DontUseID(nCmdID) ) break;

			CString strMenu;
			CToolTipManager::LoadToolTipText(nCmdID, strMenu);
			if ( strMenu.IsEmpty() ) continue;

			int nIndex = m_listCommand.AddString(strMenu);
			m_listCommand.SetItemData(nIndex, nCmdID);
		}
	}

	{	// 不要なセパレータの削除
		int   nCountSep = 0;
		int   nCountCmb = m_listCommand.GetCount();

		for (int i = 0; i < nCountCmb - 1; i++) {
			if (m_listCommand.GetItemData(i) == 0) {
				nCountSep++;

				if (m_listCommand.GetItemData(i + 1) == 0) {
					m_listCommand.DeleteString(i);
					nCountCmb--;
					i--;
				}
			}
		}

		if (nCountSep > 2) {
			if (m_listCommand.GetItemData(0) == 0) {
				m_listCommand.DeleteString(0);
			}

			int nIndexLast = m_listCommand.GetCount() - 1;

			if (m_listCommand.GetItemData(nIndexLast) == 0) {
				m_listCommand.DeleteString(nIndexLast);
			}
		}
	}
}