⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aboutdlg.cpp

📁 数字签名的例子
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		if (PtInRect(&m_riRects[2].rtRect, ptPoint))
		{
			ReleaseCapture();
			PostMessage(m_hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
		}
		break;

	case WM_LBUTTONUP:
		// 如果鼠标在超链接内
		if (m_iLinkIndex != -1)
		{
			// 如果 HIWORD(ptzUrl) 为 0,表示命令,否则表示超链接
			if (HIWORD(m_liLinks[m_iLinkIndex].ptzUrl))
			{
				ShellExecute(NULL, NULL, m_liLinks[m_iLinkIndex].ptzUrl, NULL, NULL, SW_NORMAL);
			}
			else
			{
				PostMessage(m_hWnd, WM_COMMAND, (WPARAM) m_liLinks[m_iLinkIndex].ptzUrl, 0);
			}
		}
		else
		{
			// 关闭对话框
			Close();
		}
		break;

	case WM_COMMAND:
		// 命令消息
		OnCommand(wParam, lParam);
		break;

	case WM_TIMER:
	case WM_RBUTTONUP:
		// 关闭对话框
		Close();
		break;
	}

	return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 绘制对话框
VOID CAboutDlg::OnPaint(HDC hDC)
{
	INT i;
	INT j;
	HDC hMem;
	HPEN hPen;
	HFONT hFont;
	HBRUSH hBrush;
	POINT ptPoint;
	HBITMAP hBitmap;
	static RECT s_rtRect = {0, 0, VAL_AboutDlg_Width, VAL_AboutDlg_Height};

	// 开始绘制
	hMem = CreateCompatibleDC(hDC);
	hBitmap = (HBITMAP) SelectObject(hMem, CreateCompatibleBitmap(hDC, VAL_AboutDlg_Width, VAL_AboutDlg_Height));
	FillRect(hMem, &s_rtRect, (HBRUSH) GetStockObject(WHITE_BRUSH));

	// 绘制水平线组
	for (i = 0; i < _NumOf(m_liLines); i++)
	{
		hPen = (HPEN) SelectObject(hMem, CreatePen(PS_SOLID, 0, m_liLines[i].crColor));
		for(j = m_liLines[i].rtRect.top; j < m_liLines[i].rtRect.bottom; j += 2)
		{
			MoveToEx(hMem, m_liLines[i].rtRect.left, j, NULL);
			LineTo(hMem, m_liLines[i].rtRect.right, j);
		}
		DeleteObject(SelectObject(hMem, hPen));
	}

	// 绘制矩形区域
	for (i = 0; i < _NumOf(m_riRects); i++)
	{
		hBrush = CreateSolidBrush(m_riRects[i].crColor);
		FillRect(hMem, &m_riRects[i].rtRect, hBrush);
		DeleteObject(hBrush);
	}

	// 绘制图标
	DrawIcon(hMem,
		m_riRects[2].rtRect.left + (_RectWidth(m_riRects[2].rtRect) - 32) / 2,
		m_riRects[2].rtRect.top + (_RectHeight(m_riRects[2].rtRect) - 32) / 2,
		LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_Main)));

	// 绘制超链接
	GetCursorPos(&ptPoint);
	MapWindowPoints(NULL, m_hWnd, &ptPoint, 1);
	m_iLinkIndex = GetLinkIndex(ptPoint);
	PaintLinks(hMem);

	// 使用对话框默认字体、透明背景绘制文本
	SetBkMode(hMem, TRANSPARENT);
	SelectObject(hMem, (HFONT) GetStockObject(DEFAULT_GUI_FONT));
	for (i = 0; i < _NumOf(m_tiTexts); i++)
	{
		SetTextColor(hMem, m_tiTexts[i].crColor);
		TextOut(hMem, m_tiTexts[i].x, m_tiTexts[i].y, m_tiTexts[i].tzText, lstrlen(m_tiTexts[i].tzText));
	}

	// 绘制指定字体的文本
	for (i = 0; i < _NumOf(m_ftiTexts); i++)
	{
		hFont = (HFONT) SelectObject(hMem, CreateFontIndirect(&m_ftiTexts[i].lfFont));
		SetTextColor(hMem, m_ftiTexts[i].crColor);
		TextOut(hMem, m_ftiTexts[i].x, m_ftiTexts[i].y, m_ftiTexts[i].ptzText, lstrlen(m_ftiTexts[i].ptzText));
		DeleteObject(SelectObject(hMem, hFont));
	}

	// 结束绘制
	BitBlt(hDC, 0, 0, VAL_AboutDlg_Width, VAL_AboutDlg_Height, hMem, 0, 0, SRCCOPY);
	DeleteObject(SelectObject(hMem, hBitmap));
	DeleteDC(hMem);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 命令处理
VOID CAboutDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
	switch (LOWORD(wParam))
	{
	case IDOK:
	case IDCANCEL:
		// 关闭对话框
		Close();
		break;

	case IDC_CheckUpdate:
		// 检查更新
		//CBitLive::Live(m_hWnd);
		break;

	/*case IDC_BitLive:
		// 响应更新消息
		switch (HIWORD(wParam))
		{
		case BLL_Check:
		case BLL_CheckErr:
		case BLL_News:
		case BLL_Update:
		case BLL_Progress:
		case BLL_UpdateEnd:
			SetStatusText((PTSTR) lParam);
			break;

		case BLL_UpToDate:
			SetStatusText((PTSTR) lParam);
			//CBitLive::Cancel();
			break;

		case BLL_NewsBox:
			MessageBox(m_hWnd, (PTSTR) lParam, INI_BitLive, MB_ICONINFORMATION);
			break;

		case BLL_UpdateErr:
			MessageBox(m_hWnd, (PTSTR) lParam, INI_BitLive, MB_ICONSTOP);
			break;

		case BLL_Query:
		case BLL_Confirm:
			if (MessageBox(m_hWnd, (PTSTR) lParam, INI_BitLive, MB_ICONQUESTION | MB_YESNO) == IDNO)
			{
				//CBitLive::Cancel();
			}
			break;

		case BLL_Exit:
			Close();
			PostQuitMessage(0);
			break;
		}*/
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 获取指定点的超链接
INT CAboutDlg::GetLinkIndex(POINT ptPoint)
{
	INT i;

	for (i = 0; i < _NumOf(m_liLinks); i++)
	{
		if (PtInRect(&m_liLinks[i].rtRect, ptPoint))
		{
			return i;
		}
	}

	return PtInRect(&m_riRects[2].rtRect, ptPoint) ? -2 : -1;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 绘制超链接
VOID CAboutDlg::PaintLinks(HDC hMem)
{
	INT i;
	BOOL bGetDC;
	HFONT hFont;
	LOGFONT lfFont;
	PTSTR ptzCursor;

	if (hMem == NULL)
	{
		hMem = GetDC(m_hWnd);
		bGetDC = TRUE;
	}
	else
	{
		bGetDC = FALSE;
	}

	GetObject((HFONT) GetStockObject(DEFAULT_GUI_FONT), sizeof(LOGFONT), &lfFont);
	for (i = 0; i < _NumOf(m_liLinks); i++)
	{
		lfFont.lfUnderline = (i == m_iLinkIndex);
		hFont = (HFONT) SelectObject(hMem, CreateFontIndirect(&lfFont));
		SetTextColor(hMem, lfFont.lfUnderline ? COLOR_AboutDlg_HotLink : COLOR_AboutDlg_Link);

		// 计算矩形框,绘制文本
		m_liLinks[i].rtRect.bottom = m_liLinks[i].rtRect.top +
			DrawText(hMem, m_liLinks[i].tzTitle, -1, &m_liLinks[i].rtRect,
			DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER | DT_CALCRECT);
		DrawText(hMem, m_liLinks[i].tzTitle, -1, &m_liLinks[i].rtRect, DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER);

		DeleteObject(SelectObject(hMem, hFont));
	}

	if ((m_iLinkIndex >= 0))
	{
		SetStatusText(m_liLinks[m_iLinkIndex].tzTip);
		ptzCursor = IDC_HAND;
	}
	else
	{
		SetStatusText();
		ptzCursor = (m_iLinkIndex == -2) ? IDC_SIZEALL : IDC_ARROW;
	}

	if (bGetDC) ReleaseDC(m_hWnd, hMem);

	SetCursor(LoadCursor(NULL, ptzCursor));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -