Example #1
0
BOOL CPropertiesWnd::IsSelectComboItem()
{
	if (IsComboType())
	{
		CMFCPropertyGridProperty *pProp = m_wndPropList.GetCurSel();
		if (pProp && pProp->IsGroup())
		{
			CString strName(pProp->GetName());
			return (strName.CompareNoCase(_T("ITEM")) == 0);
		}
	}
	return FALSE;
}
Example #2
0
void CPropertiesWnd::OnPropDownitem()
{
	if (!IsComboType())
	{
		return;
	}

	CMFCPropertyGridProperty *pProp = m_wndPropList.GetCurSel();
	if (pProp && pProp->IsGroup())
	{
		CString strName(pProp->GetName());
		if (strName.CompareNoCase(_T("ITEM")) == 0)
		{
			CMFCPropertyGridProperty *pParentProp = pProp->GetParent();
			if (pProp == pParentProp->GetSubItem(pParentProp->GetSubItemsCount() - 1))
			{
				return;
			}

			int nEnd = 0;
			CList<CMFCPropertyGridProperty*, CMFCPropertyGridProperty*> lstSubItems;
			for (int i = pParentProp->GetSubItemsCount() - 1; i >= nEnd; i--)
			{
				CMFCPropertyGridProperty *pChildProp = pParentProp->GetSubItem(i);
				if (pChildProp)
				{
					if (pChildProp == pProp)
					{
						nEnd = i;
						lstSubItems.InsertAfter(lstSubItems.GetHeadPosition(), pChildProp);
					}
					else
					{
						lstSubItems.AddHead(pChildProp);
					}
					pParentProp->RemoveSubItem(pChildProp, FALSE);
				}
			}

			for (POSITION pos = lstSubItems.GetHeadPosition(); pos != NULL;)
			{
				CMFCPropertyGridProperty* pProp = lstSubItems.GetNext(pos);
				ASSERT_VALID(pProp);

				pParentProp->AddSubItem(pProp);
			}
			m_wndPropList.AdjustLayout();
		}
	}
}
Example #3
0
void CPropertiesWnd::OnPropDelitem()
{
	if (!IsComboType())
	{
		return;
	}

	CMFCPropertyGridProperty *pProp = m_wndPropList.GetCurSel();
	if (pProp && pProp->IsGroup())
	{
		CString strName(pProp->GetName());
		if (strName.CompareNoCase(_T("ITEM")) == 0 && AfxMessageBox(_T("Sure to delete it?"), MB_YESNO) == IDYES)
		{
			pProp->GetParent()->RemoveSubItem(pProp);
			m_wndPropList.RedrawWindow();
		}
	}
}
Example #4
0
void CPropertiesWnd::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	CMFCPropertyGridProperty * pProperty = m_wndPropList.GetCurSel();

	CString sMenuItemText;
	CIconMenu popup;
	if (pProperty && !pProperty->IsGroup() && popup.CreatePopupMenu())
	{
		sMenuItemText.LoadString(IDS_SCIEDIT_COPY);
		popup.AppendMenu(MF_STRING | MF_ENABLED, WM_COPY, sMenuItemText);

		int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);
		switch (cmd)
		{
		case 0:
			break;	// no command selected
		case WM_COPY:
			CStringUtils::WriteAsciiStringToClipboard(pProperty->GetValue(), GetSafeHwnd());
			break;
		}
	}
}