Пример #1
0
void ConEmuAbout::DonateBtns_Add(HWND hDlg, int AlignLeftId, int AlignVCenterId)
{
	if (!m_Btns[0].pImg)
		LoadResources();

	RECT rcLeft = {}, rcTop = {};
	HWND hCtrl;

	hCtrl = GetDlgItem(hDlg, AlignLeftId);
	GetWindowRect(hCtrl, &rcLeft);
	MapWindowPoints(NULL, hDlg, (LPPOINT)&rcLeft, 2);
	hCtrl = GetDlgItem(hDlg, AlignVCenterId);
	GetWindowRect(hCtrl, &rcTop);
	int nPreferHeight = rcTop.bottom - rcTop.top;
	MapWindowPoints(NULL, hDlg, (LPPOINT)&rcTop, 2);

	#ifdef _DEBUG
	DpiValue dpi;
	CDpiAware::QueryDpiForWindow(hDlg, &dpi);
	#endif

	int X = rcLeft.left;

	for (size_t i = 0; i < countof(m_Btns); i++)
	{
		if (!m_Btns[i].pImg)
			continue; // Image was failed

		TODO("Вертикальное центрирование по объекту AlignVCenterId");

		int nDispW = 0, nDispH = 0;
		if (!m_Btns[i].pImg->GetSizeForHeight(nPreferHeight, nDispW, nDispH))
		{
			_ASSERTE(FALSE && "Image not available for dpi?");
			continue; // Image was failed?
		}
		_ASSERTE(nDispW>0 && nDispH>0);
		int nY = rcTop.top + ((rcTop.bottom - rcTop.top - nDispH + 1) / 2);

		hCtrl = CreateWindow(L"STATIC", m_Btns[i].ResId,
			WS_CHILD|WS_VISIBLE|SS_NOTIFY|SS_OWNERDRAW,
			X, nY, nDispW, nDispH,
			hDlg, (HMENU)m_Btns[i].nCtrlId, g_hInstance, NULL);

		#ifdef _DEBUG
		if (!hCtrl)
			DisplayLastError(L"Failed to create image button control");
		#endif

		//X += nDispW + (10 * dpi.Ydpi / 96);
		X += nDispW + (nDispH / 3);
	}

	RegisterTip(hDlg);

	UNREFERENCED_PARAMETER(hCtrl);
}
Пример #2
0
void ConEmuAbout::DonateBtns_Add(HWND hDlg, int AlignLeftId, int AlignVCenterId)
{
	if (!m_Btns[0].hBmp)
		LoadResources();

	RECT rcLeft = {}, rcTop = {};
	HWND hCtrl;

	hCtrl = GetDlgItem(hDlg, AlignLeftId);
	GetWindowRect(hCtrl, &rcLeft);
	MapWindowPoints(NULL, hDlg, (LPPOINT)&rcLeft, 2);
	hCtrl = GetDlgItem(hDlg, AlignVCenterId);
	GetWindowRect(hCtrl, &rcTop);
	MapWindowPoints(NULL, hDlg, (LPPOINT)&rcTop, 2);

	int nDisplayDpi = gpSetCls->QueryDpi();

	int X = rcLeft.left;

	for (size_t i = 0; i < countof(m_Btns); i++)
	{
		if (!m_Btns[i].hBmp)
			continue; // Image was failed

		TODO("Вертикальное центрирование по объекту AlignVCenterId");

		int nDispW = m_Btns[i].bmp.bmWidth * nDisplayDpi / 96;
		int nDispH = m_Btns[i].bmp.bmHeight * nDisplayDpi / 96;
		int nY = rcTop.top + ((rcTop.bottom - rcTop.top - nDispH + 1) / 2);

		hCtrl = CreateWindow(L"STATIC", m_Btns[i].ResId,
			WS_CHILD|WS_VISIBLE|SS_NOTIFY|SS_OWNERDRAW,
			X, nY, nDispW, nDispH,
			hDlg, (HMENU)m_Btns[i].nCtrlId, g_hInstance, NULL);

		#ifdef _DEBUG
		if (!hCtrl)
			DisplayLastError(L"Failed to create image button control");
		#endif

		X += nDispW + (10 * nDisplayDpi / 96);
	}

	RegisterTip(hDlg);

	UNREFERENCED_PARAMETER(hCtrl);
}