コード例 #1
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);
		}
	}
}
コード例 #2
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);
}