void CXTPPropertyGridItemDate::OnInplaceButtonDown(CXTPPropertyGridInplaceButton* pButton)
{
	if (m_pGrid->SendNotifyMessage(XTP_PGN_INPLACEBUTTONDOWN, (LPARAM)pButton) == TRUE)
		return;

	if (!OnRequestEdit())
		return;

	CXTPPropertyGridInplaceMonthCal* pMonthCtrl = new CXTPPropertyGridInplaceMonthCal(this);


#if _MSC_VER < 1200 // MFC 5.0
	INITCOMMONCONTROLSEX icex;
	icex.dwSize = sizeof(icex);
	icex.dwICC = ICC_DATE_CLASSES;
	VERIFY(InitCommonControlsEx(&icex));
#else
	VERIFY(AfxDeferRegisterClass(AFX_WNDCOMMCTL_DATE_REG));
#endif // _MSC_VER < 1200


	CRect rect(0, 0, 0, 0);
	pMonthCtrl->CreateEx(WS_EX_TOPMOST | (m_pGrid->GetExStyle() & WS_EX_LAYOUTRTL), MONTHCAL_CLASS, NULL, WS_BORDER | WS_POPUP | WS_VISIBLE, rect, m_pGrid, 0);

	SYSTEMTIME sysTime;
	if (GetAsSystemTime(sysTime))
		pMonthCtrl->SendMessage(MCM_SETCURSEL, 0, (LPARAM) &sysTime);

	if (pMonthCtrl->GetMinReqRect(rect))
	{
		CRect rcItem = GetItemRect();
		rect.SetRect(rcItem.right - rect.Width(), rcItem.bottom, rcItem.right, rcItem.bottom + rect.Height());

		m_pGrid->ClientToScreen(&rect);

		CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect);
		if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y)
			rect.OffsetRect(0, - rect.Height() - rcItem.Height() - 1);

		if (rect.left < rcWork.left)
			rect.OffsetRect(rcWork.left - rect.left, 0);

		if (rect.right > rcWork.right)
			rect.OffsetRect(rcWork.right - rect.right, 0);

		pMonthCtrl->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
	}


	pMonthCtrl->SetOwner(m_pGrid);
	pMonthCtrl->SetFocus();
}
void CXTPPropertyGridInplaceMultilineEdit::Create(CXTPPropertyGridItem* pItem, CRect rect)
{
	ASSERT(pItem && pItem->GetGrid());
	if (!pItem)
		return;

	CRect rcValue(rect);
	rcValue.left = pItem->GetGrid()->GetDividerPos() + 1;

	CWnd* pParent = (CWnd*)pItem->GetGrid();
	m_pItem = pItem;

	if (!m_hWnd)
	{
		CEdit::CreateEx(WS_EX_TOOLWINDOW, _T("EDIT"), m_pItem->GetValue(), ES_MULTILINE | WS_CHILD | WS_BORDER | WS_VSCROLL | ES_AUTOVSCROLL, CRect(0, 0, 0, 0), pParent, 0);
		SetOwner(pParent);
	}
	SetFont(pParent->GetFont());


	int dx = rect.right - rcValue.left;

	CWindowDC dc(pParent);
	CXTPFontDC font(&dc, pParent->GetFont());
	int nHeight = dc.GetTextExtent(_T(" "), 1).cy;

	rect.top = rect.bottom;
	rect.bottom += nHeight * pItem->GetDropDownItemCount() + 4;
	rect.left = rect.right - __min(dx, rect.Width() - XTP_PGI_EXPAND_BORDER);

	pParent->ClientToScreen(&rect);

	CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect);
	if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y)
	{
		rect.OffsetRect(0, - rect.Height() - rcValue.Height() - 1);
	}
	if (rect.left < rcWork.left) rect.OffsetRect(rcWork.left - rect.left, 0);
	if (rect.right > rcWork.right) rect.OffsetRect(rcWork.right - rect.right, 0);


	SetFocus();


	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, 0);
	ModifyStyle(WS_CHILD, WS_POPUP);
	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, (LONG_PTR)pParent->m_hWnd);

	SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOOWNERZORDER);

	CXTPMouseMonitor::SetupHook(this);
}
Ejemplo n.º 3
0
void CXTPPopupControl::TrackMove()
{
	SetCapture();

	CPoint ptStart;
	GetCursorPos(&ptStart);

	CXTPWindowRect rcStart(this);

	while (GetCapture() == this)
	{
		MSG msg;

		if (!::GetMessage(&msg, NULL, 0, 0))
		{
			AfxPostQuitMessage((int)msg.wParam);
			break;
		}

		if (msg.message == WM_LBUTTONUP) break;
		else if (msg.message == WM_MOUSEMOVE)
		{
			CPoint pt(msg.pt);
			CRect rc(rcStart);
			rc.OffsetRect(pt - ptStart);

			CRect rcDeskWnd = XTPMultiMonitor()->GetWorkArea(msg.pt);

			if (rc.left < rcDeskWnd.left) rc.OffsetRect(rcDeskWnd.left - rc.left, 0);
			if (rc.top < rcDeskWnd.top) rc.OffsetRect(0, rcDeskWnd.top - rc.top);
			if (rc.right > rcDeskWnd.right) rc.OffsetRect(rcDeskWnd.right - rc.right, 0);
			if (rc.bottom > rcDeskWnd.bottom) rc.OffsetRect(0, rcDeskWnd.bottom - rc.bottom);

			MoveWindow(rc);
		}
		else if (msg.message == WM_KEYDOWN)
		{
			if (msg.wParam == VK_ESCAPE)
				break;
		}
		else
			DispatchMessage(&msg);

	}
	ReleaseCapture();


	m_stateTarget.rcPopup = m_stateCurrent.rcPopup = CXTPWindowRect(this);
	m_ptPopup = m_stateCurrent.rcPopup.BottomRight();

	Notify(XTP_PCN_POSCHANGED, (LPARAM)this);
}
Ejemplo n.º 4
0
CSize CXTPRibbonTabPopupToolBar::CalcDynamicLayout(int, DWORD /*nMode*/)
{
	CRect rcRibbonBar;
	m_pRibbonBar->GetWindowRect(rcRibbonBar);

	CRect rcRibbonTab = m_pRibbonTab->GetRect();
	m_pRibbonBar->ClientToScreen(rcRibbonTab);

	CRect rcWork = XTPMultiMonitor()->GetWorkArea(rcRibbonTab);

	int nHeight = m_pRibbonBar->CalcGroupsHeight();
	int nWidth = rcRibbonBar.Width();

	m_ptPopup.y = m_rcExclude.bottom;
	m_ptPopup.x = rcRibbonBar.left;

	if (m_ptPopup.x < rcWork.left)
	{
		nWidth -= rcWork.left - m_ptPopup.x;
		m_ptPopup.x = rcWork.left;
	}

	if (m_ptPopup.x + nWidth > rcWork.right)
	{
		nWidth = rcWork.right - m_ptPopup.x - 4;
	}

	if (m_ptPopup.y + nHeight > rcWork.bottom)
	{
		m_ptPopup.y = m_rcExclude.top - nHeight;
	}

	CClientDC dc(this);
	CXTPFontDC font(&dc, GetPaintManager()->GetCommandBarFont(this));

	UpdateShortcuts();

	m_rcGroups.SetRect(0, 0, nWidth, nHeight);
	m_pRibbonTab->GetGroups()->CalcDynamicSize(&dc, m_rcGroups.Width(), LM_COMMIT,
		CRect(m_rcGroups.left + 4, m_rcGroups.top + 3, 6, 3));

	m_rcTearOffGripper.SetRectEmpty();


	return CSize(nWidth, nHeight);
}
Ejemplo n.º 5
0
CPoint CXTPPopupControl::GetPopupPos() const
{
	if (m_ptPopup != CPoint(-1, -1))
		return m_ptPopup;

	if (m_nPopupLocation == xtpPopupLocationNearTaskBar)
	{
		APPBARDATA abd;
		ZeroMemory(&abd, sizeof(APPBARDATA));
		abd.cbSize = sizeof(APPBARDATA);

		if (SHAppBarMessage(ABM_GETTASKBARPOS, &abd))
		{
			CRect rc = XTPMultiMonitor()->GetWorkArea(&abd.rc);

			if (rc.CenterPoint().y < abd.rc.top)
				return CPoint(rc.right, rc.bottom);

			if (rc.CenterPoint().x > abd.rc.right)
				return CPoint(rc.left + m_szPopup.cx, rc.bottom);

			if (rc.CenterPoint().y > abd.rc.bottom)
				return CPoint(rc.right, rc.top + m_szPopup.cy);

			if (rc.CenterPoint().x < abd.rc.left)
				return CPoint(rc.right, rc.bottom);
		}
	}


	//get desktop parameters
	CRect rcDeskWnd;
	::SystemParametersInfo(SPI_GETWORKAREA, 0, &rcDeskWnd, 0);

	if (m_nPopupLocation == xtpPopupLocationCenter)
	{
		return CPoint(rcDeskWnd.CenterPoint().x + m_szPopup.cx / 2, rcDeskWnd.CenterPoint().y + m_szPopup.cy / 2);
	}

		//set position
	return rcDeskWnd.BottomRight();
}
void CXTPPropertyGridInplaceList::Create(CXTPPropertyGridItem* pItem, CRect rect)
{
	ASSERT(pItem && pItem->GetGrid());
	if (!pItem)
		return;

	CRect rcValue(rect);
	rcValue.left = pItem->GetGrid()->GetDividerPos() + 1;

	CWnd* pParent = (CWnd*)pItem->GetGrid();
	m_pItem = pItem;

	DestroyWindow();

	if (!m_hWnd)
	{
		CListBox::CreateEx(WS_EX_TOOLWINDOW | (pParent->GetExStyle() & WS_EX_LAYOUTRTL), _T("LISTBOX"), _T(""),
			LBS_NOTIFY | WS_CHILD | WS_VSCROLL | WS_BORDER | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS, CRect(0, 0, 0, 0), pParent, 0);
		SetOwner(pParent);


		if (m_bShowShadow && XTPSystemVersion()->IsWinXPOrGreater())
			SetClassLongPtr(m_hWnd, GCL_STYLE, GetClassLongPtr(m_hWnd, GCL_STYLE) | 0x00020000);
	}
	SetFont(pParent->GetFont());

	ResetContent();

	CXTPPropertyGridItemConstraints* pList = pItem->GetConstraints();


	int dx = rect.right - rcValue.left;

	CWindowDC dc(pParent);
	CXTPFontDC font(&dc, pParent->GetFont());
	int nHeight = dc.GetTextExtent(_T(" "), 1).cy + 3;

	for (int i = 0; i < pList->GetCount(); i++)
	{
		CXTPPropertyGridItemConstraint* pConstraint = pList->GetConstraintAt(i);

		CString str = pConstraint->m_strConstraint;
		int nIndex = AddString(str);
		SetItemDataPtr(nIndex, pConstraint);

		CSize sz = pItem->OnMergeItemConstraint(&dc, pConstraint);

		dx = max(dx, sz.cx);
		nHeight = max(nHeight, sz.cy);

		if (pItem->GetValue() == str)
			SetCurSel(nIndex);
	}

	SetItemHeight(0, nHeight);

	rect.top = rect.bottom;
	rect.bottom += nHeight * __min(pItem->GetDropDownItemCount(), GetCount()) + 2;
	rect.left = rect.right - __min(dx, rect.Width() - XTP_PGI_EXPAND_BORDER);

	pParent->ClientToScreen(&rect);

	CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect);
	if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y)
	{
		rect.OffsetRect(0, - rect.Height() - rcValue.Height() - 1);
	}
	if (rect.left < rcWork.left) rect.OffsetRect(rcWork.left - rect.left, 0);
	if (rect.right > rcWork.right) rect.OffsetRect(rcWork.right - rect.right, 0);


	SetFocus();


	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, 0);
	ModifyStyle(WS_CHILD, WS_POPUP);
	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, (LONG_PTR)pParent->m_hWnd);

	SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOOWNERZORDER);

	CXTPMouseMonitor::SetupHook(this);
}
void CXTPReportInplaceList::Create(XTP_REPORTRECORDITEM_ARGS* pItemArgs, CXTPReportRecordItemConstraints* pConstaints)
{
	SetItemArgs(pItemArgs);

	CRect rect(pItemArgs->rcItem);

	if (!m_hWnd)
	{
		CListBox::CreateEx(WS_EX_TOOLWINDOW | (pControl->GetExStyle() & WS_EX_LAYOUTRTL), _T("LISTBOX"), _T(""), LBS_NOTIFY | WS_CHILD | WS_BORDER | WS_VSCROLL, CRect(0, 0, 0, 0), pControl, 0);
		SetOwner(pControl);
	}

	SetFont(pControl->GetPaintManager()->GetTextFont());
	ResetContent();

	int dx = rect.right - rect.left + 1;

	CWindowDC dc(pControl);
	CXTPFontDC font(&dc, GetFont());
	int nThumbLength = GetSystemMetrics(SM_CXHTHUMB);

	CString strCaption = pItem->GetCaption(pColumn);
	DWORD dwData = pItem->GetSelectedConstraintData(pItemArgs);

	for (int i = 0; i < pConstaints->GetCount(); i++)
	{
		CXTPReportRecordItemConstraint* pConstaint = pConstaints->GetAt(i);
		CString str = pConstaint->m_strConstraint;
		int nIndex = AddString(str);
		SetItemDataPtr(nIndex, pConstaint);

		dx = max(dx, dc.GetTextExtent(str).cx + nThumbLength);

		if ((dwData == (DWORD)-1 && strCaption == str) || (dwData == pConstaint->m_dwData))
			SetCurSel(nIndex);
	}

	int nHeight = GetItemHeight(0);
	rect.top = rect.bottom;
	//rect.bottom += nHeight * min(10, GetCount()) + 2;
	rect.bottom += nHeight * min(m_Items2Show, GetCount()) + 2;
	rect.left = rect.right - dx;

	pControl->ClientToScreen(&rect);

	CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect);
	if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y)
		rect.OffsetRect(0, - rect.Height() - pItemArgs->rcItem.Height());

	if (rect.left < rcWork.left) rect.OffsetRect(rcWork.left - rect.left, 0);
	if (rect.right > rcWork.right) rect.OffsetRect(rcWork.right - rect.right, 0);

	SetFocus();

	if (!m_hWnd) // Can be destroyed after focus set
		return;

	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, 0);
	ModifyStyle(WS_CHILD, WS_POPUP);
	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, (LONG_PTR)pControl->m_hWnd);

	SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOOWNERZORDER);

	CXTPMouseMonitor::SetupHook(this);
}