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

📄 classxp.c

📁 OA系统权限管理设计任何系统都离不开权限的管理,有一个好的权限管理模块,不仅使我们的系统操作自如,管理方便,也为系统添加亮点
💻 C
📖 第 1 页 / 共 3 页
字号:
		SetTextColor(Mdcxp.hMemDC,
			((pCxp->dwState & CXPS_INDETERMINATE) || (pCxp->dwState & CXPS_DISABLED)) ?
			0x0094A2A5: 0x00000000);
		hHandle = (HANDLE) SelectObject(Mdcxp.hMemDC,
			(HGDIOBJ) SendMessage(pCxp->hWnd, WM_GETFONT, 0, 0));
		DrawText(Mdcxp.hMemDC, szTemp, -1, &Rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER);
		SelectObject(Mdcxp.hMemDC, (HGDIOBJ) hHandle);
	}

	Mdcxp.bTransfer = TRUE;
	ReleaseMemDCXP(&Mdcxp);
}
////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////
// 绘制复选框
VOID WINAPI DrawCheckBoxXP(PCLASSXP pCxp)
{
	int i;
	RECT Rect;
	MEMDCXP Mdcxp;
	HANDLE hHandle;
	char szTemp[256];
	COLORREF crColor;
	static COLORREF s_crGradientXP[][4] =
	{
		{0x00A5B2B5, 0x00CED7D6, 0x00CED7D6, 0x00DEEFF7},
		{0x00CEF3FF, 0x0063CBFF, 0x0063CBFF, 0x0031B2FF},
		{0x00D6DFDE, 0x00EFF3F7, 0x00EFF3F7, 0x00FFFFFF}
	};

	// 获取内存兼容设备场景
	Mdcxp.hWnd = pCxp->hWnd;
	Mdcxp.bTransfer = FALSE;
	Mdcxp.hBitmap = NULL;
	GetMemDCXP(&Mdcxp);

	// 获取窗口大小
	GetWindowRect(pCxp->hWnd, &Rect);
	Rect.right -= Rect.left;
	Rect.bottom -= Rect.top;
	Rect.left = Rect.top = 0;

	// 填充背景
	FillRect(Mdcxp.hMemDC, &Rect, GetSysColorBrush(COLOR_BTNFACE));

	// 画最外面的框
	Rect.left = 0;
	Rect.right = 13;
	Rect.top = (Rect.bottom - 13) / 2;
	Rect.bottom = Rect.top + 13;
	hHandle = (HANDLE) CreateSolidBrush(
		(pCxp->dwState & CXPS_DISABLED) ? (GetSysColor(COLOR_BTNFACE) - 0x00202020) : 0x00845118);
	FrameRect(Mdcxp.hMemDC, &Rect, (HBRUSH) hHandle);
	DeleteObject((HGDIOBJ) hHandle);

	// 画热点框渐变背景
	InflateRect(&Rect, -1, -1);
	if (pCxp->dwState & CXPS_DISABLED)
		FillRect(Mdcxp.hMemDC, &Rect, GetStockObject(WHITE_BRUSH));
	else
	{
		if (pCxp->dwState & CXPS_PRESSED)
			i = 0;
		else if (pCxp->dwState & CXPS_HOTLIGHT)
			i = 1;
		else
			i = 2;
		GradientRectXP(Mdcxp.hMemDC, &Rect, s_crGradientXP[i]);
	}

	// 画内框
	InflateRect(&Rect, -2, -2);
	if ((pCxp->dwState & CXPS_INDETERMINATE) ||
		((pCxp->dwState & CXPS_HOTLIGHT) && (!(pCxp->dwState & CXPS_PRESSED))))
	{
		if (pCxp->dwState & CXPS_INDETERMINATE)
		{
			if (pCxp->dwState & CXPS_DISABLED)
				crColor = 0x00BDCBCE;
			else if (pCxp->dwState & CXPS_PRESSED)
				crColor = 0x00188A18;
			else if (pCxp->dwState & CXPS_HOTLIGHT)
				crColor = 0x0021A221;
			else
				crColor = 0x0073C373;
		}
		else if (pCxp->dwState & CXPS_CHECKED)
			crColor = 0x00F7F7F7;
		else
			crColor = 0x00E7E7E7;

		hHandle = (HANDLE) CreateSolidBrush(crColor);
		FillRect(Mdcxp.hMemDC, &Rect, (HBRUSH) hHandle);
		DeleteObject((HGDIOBJ) hHandle);
	}


	// 画框内选中标志
	if (pCxp->dwState & CXPS_CHECKED)
	{
		hHandle = (HANDLE) SelectObject(Mdcxp.hMemDC,
			CreatePen(PS_SOLID, 1, (pCxp->dwState & CXPS_DISABLED) ? 0x000BDCBCE : 0x0021A221));
		for (i = 3; i < 10; i++)
		{
			MoveToEx(Mdcxp.hMemDC, i, Rect.top + ((i < 6) ? i - 1 : (9 - i)), NULL);
			LineTo(Mdcxp.hMemDC, i, Rect.top + ((i < 6) ? i + 2 : (12 - i)));
		}
		DeleteObject(SelectObject(Mdcxp.hMemDC, (HGDIOBJ) hHandle));
	}

	// 画文字
	if (GetWindowText(pCxp->hWnd, szTemp, sizeof(szTemp)))
	{
		SetTextColor(Mdcxp.hMemDC, GetSysColor((pCxp->dwState & CXPS_DISABLED) ?  COLOR_GRAYTEXT: COLOR_BTNTEXT));
		hHandle = (HANDLE) SelectObject(Mdcxp.hMemDC,
			(HGDIOBJ) SendMessage(pCxp->hWnd, WM_GETFONT, 0, 0));

		Rect.left = 18;
		Rect.top -= 2;
		Rect.bottom = Rect.top + 1 + DrawText(Mdcxp.hMemDC, szTemp, -1, &Rect,
			DT_CALCRECT | DT_SINGLELINE | DT_VCENTER);

		DrawText(Mdcxp.hMemDC, szTemp, -1, &Rect, DT_SINGLELINE | DT_VCENTER);
		SelectObject(Mdcxp.hMemDC, (HGDIOBJ) hHandle);

		// 如果有焦点,画出焦点框
		if (pCxp->dwState & CXPS_FOCUS)
		{
			InflateRect(&Rect, 1, 1);
			DrawFocusRect(Mdcxp.hMemDC, &Rect);
		}
	}
	Mdcxp.bTransfer = TRUE;
	ReleaseMemDCXP(&Mdcxp);
}
////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////
// 绘制单选框
VOID WINAPI DrawRadioBoxXP(PCLASSXP pCxp)
{
	int i;
	RECT Rect;
	MEMDCXP Mdcxp;
	HANDLE hHandle;
	char szTemp[256];
	COLORREF crColor;
	static COLORREF s_crGradientXP[][4] =
	{
		{0x00A5B2B5, 0x00CED7D6, 0x00CED7D6, 0x00DEEFF7},
		{0x00CEF3FF, 0x0063CBFF, 0x0063CBFF, 0x0031B2FF},
		{0x00D6DFDE, 0x00EFF3F7, 0x00EFF3F7, 0x00FFFFFF}
	};

	// 获取内存兼容设备场景
	Mdcxp.hWnd = pCxp->hWnd;
	Mdcxp.bTransfer = FALSE;
	Mdcxp.hBitmap = NULL;
	GetMemDCXP(&Mdcxp);

	// 获取窗口大小
	GetWindowRect(pCxp->hWnd, &Rect);
	Rect.right -= Rect.left;
	Rect.bottom -= Rect.top;
	Rect.left = Rect.top = 0;

	// 填充背景
	FillRect(Mdcxp.hMemDC, &Rect, GetSysColorBrush(COLOR_BTNFACE));

	// 画最外面的框
	Rect.left = 0;
	Rect.right = 13;
	Rect.top = (Rect.bottom - 13) / 2;
	Rect.bottom = Rect.top + 13;
	hHandle = (HANDLE) CreateSolidBrush(
		(pCxp->dwState & CXPS_DISABLED) ? (GetSysColor(COLOR_BTNFACE) - 0x00202020) : 0x00845118);
	FrameRect(Mdcxp.hMemDC, &Rect, (HBRUSH) hHandle);
	DeleteObject((HGDIOBJ) hHandle);

	// 画热点框渐变背景
	InflateRect(&Rect, -1, -1);
	if (pCxp->dwState & CXPS_DISABLED)
		FillRect(Mdcxp.hMemDC, &Rect, GetStockObject(WHITE_BRUSH));
	else
	{
		if (pCxp->dwState & CXPS_PRESSED)
			i = 0;
		else if (pCxp->dwState & CXPS_HOTLIGHT)
			i = 1;
		else
			i = 2;
		GradientRectXP(Mdcxp.hMemDC, &Rect, s_crGradientXP[i]);
	}

	// 画内框
	InflateRect(&Rect, -2, -2);
	if ((pCxp->dwState & CXPS_INDETERMINATE) ||
		((pCxp->dwState & CXPS_HOTLIGHT) && (!(pCxp->dwState & CXPS_PRESSED))))
	{
		if (pCxp->dwState & CXPS_INDETERMINATE)
		{
			if (pCxp->dwState & CXPS_DISABLED)
				crColor = 0x00BDCBCE;
			else if (pCxp->dwState & CXPS_PRESSED)
				crColor = 0x00188A18;
			else if (pCxp->dwState & CXPS_HOTLIGHT)
				crColor = 0x0021A221;
			else
				crColor = 0x0073C373;
		}
		else if (pCxp->dwState & CXPS_CHECKED)
			crColor = 0x00F7F7F7;
		else
			crColor = 0x00E7E7E7;

		hHandle = (HANDLE) CreateSolidBrush(crColor);
		FillRect(Mdcxp.hMemDC, &Rect, (HBRUSH) hHandle);
		DeleteObject((HGDIOBJ) hHandle);
	}


	// 画框内选中标志
	if (pCxp->dwState & CXPS_CHECKED)
	{
		hHandle = (HANDLE) SelectObject(Mdcxp.hMemDC,
			CreatePen(PS_SOLID, 1, (pCxp->dwState & CXPS_DISABLED) ? 0x000BDCBCE : 0x0021A221));
		for (i = 3; i < 10; i++)
		{
			MoveToEx(Mdcxp.hMemDC, i, Rect.top + ((i < 6) ? i - 1 : (9 - i)), NULL);
			LineTo(Mdcxp.hMemDC, i, Rect.top + ((i < 6) ? i + 2 : (12 - i)));
		}
		DeleteObject(SelectObject(Mdcxp.hMemDC, (HGDIOBJ) hHandle));
	}

	// 画文字
	if (GetWindowText(pCxp->hWnd, szTemp, sizeof(szTemp)))
	{
		SetTextColor(Mdcxp.hMemDC, GetSysColor((pCxp->dwState & CXPS_DISABLED) ?  COLOR_GRAYTEXT: COLOR_BTNTEXT));
		hHandle = (HANDLE) SelectObject(Mdcxp.hMemDC,
			(HGDIOBJ) SendMessage(pCxp->hWnd, WM_GETFONT, 0, 0));

		Rect.left = 18;
		Rect.top -= 2;
		Rect.bottom = Rect.top + 1 + DrawText(Mdcxp.hMemDC, szTemp, -1, &Rect,
			DT_CALCRECT | DT_SINGLELINE | DT_VCENTER);

		DrawText(Mdcxp.hMemDC, szTemp, -1, &Rect, DT_SINGLELINE | DT_VCENTER);
		SelectObject(Mdcxp.hMemDC, (HGDIOBJ) hHandle);

		// 如果有焦点,画出焦点框
		if (pCxp->dwState & CXPS_FOCUS)
		{
			InflateRect(&Rect, 1, 1);
			DrawFocusRect(Mdcxp.hMemDC, &Rect);
		}
	}
	Mdcxp.bTransfer = TRUE;
	ReleaseMemDCXP(&Mdcxp);
}
////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////
// 绘制编辑框
VOID WINAPI DrawEditBoxXP(PCLASSXP pCxp)
{
	HDC hDC;
	RECT Rect;
	LONG lExStyle;
	HANDLE hHandle;

	lExStyle = GetWindowLong(pCxp->hWnd, GWL_EXSTYLE);
	if ((GetWindowLong(pCxp->hWnd, GWL_STYLE) & WS_BORDER) ||
		(lExStyle & WS_EX_CLIENTEDGE) || (lExStyle & WS_EX_STATICEDGE))
	{
		// 由于绘制的东西很少,所以直接绘制而不使用 MEMDCXP 方式
		hDC = GetWindowDC(pCxp->hWnd);

		// 获取窗口大小
		GetWindowRect(pCxp->hWnd, &Rect);
		Rect.right -= Rect.left;
		Rect.bottom -= Rect.top;
		Rect.top = Rect.left = 0;

		// 绘制外框
		hHandle = (HANDLE) CreateSolidBrush(
			(pCxp->dwState & CXPS_DISABLED) ? (GetSysColor(COLOR_BTNFACE) - 0x00202020) : 0x00BD9E7B);
		FrameRect(hDC, &Rect, (HBRUSH) hHandle);
		DeleteObject((HGDIOBJ) hHandle);

		// 绘制内框
		if ((lExStyle & WS_EX_CLIENTEDGE) || (lExStyle & WS_EX_STATICEDGE))
		{
			InflateRect(&Rect, -1, -1);
			hHandle = (HANDLE) GetSysColorBrush(
				(pCxp->dwState & CXPS_DISABLED) || (pCxp->dwState & CXPS_READONLY) ? COLOR_BTNFACE : COLOR_WINDOW);
			FrameRect(hDC, &Rect, (HBRUSH) hHandle);
			if ((lExStyle & WS_EX_CLIENTEDGE) && (lExStyle & WS_EX_STATICEDGE))
			{
				InflateRect(&Rect, -1, -1);
				FrameRect(hDC, &Rect, hHandle);
			}
		}

		// 释放设备场景
		ReleaseDC(pCxp->hWnd, hDC);
	}
}
////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////
// 绘制组合框
VOID WINAPI DrawComboBoxXP(PCLASSXP pCxp)
{
	int i;
	RECT Rect;
	MEMDCXP Mdcxp;
	HANDLE hHandle;
	static COLORREF s_crGradientXP[][4] =
	{
		{0x00EFF3F7, 0x00DEE7E7, 0x00DEE3E7, 0x00DEE3E7},
		{0x00DEAEA5, 0x00F7CBBD, 0x00DE8273, 0x00F7C7B5},
		{0x00EFC7B5, 0x00E7AE94, 0x00DEA284, 0x00DEA68C},
		{0x00FFE3D6, 0x00F7CBBD, 0x00F7C3AD, 0x00F7C7B5},

		{0x00F7F7F7, 0x00EFF3F7, 0x00EFF3F7, 0x00EFF3F7},
		{0x00DEC3BD, 0x00DEB6AD, 0x00FFE3DE, 0x00F7E3DE},
		{0x00EFDBCE, 0x00EFCFC6, 0x00E7CFC6, 0x00E7CBBD},
		{0x00FFEFE7, 0x00FFE7DE, 0x00FFE3DE, 0x00F7E3DE},

		{0x00F7F7F7, 0x00E7EFEF, 0x00E7EBEF, 0x00DEE7E7},
		{0x00F78E6B, 0x00F79684, 0x00EF9E8C, 0x00EFDFD6},
		{0x00FFFFFF, 0x00FFE3CE, 0x00FFDFC6, 0x00FFDBBD},
		{0x00FFEBE7, 0x00FFCFBD, 0x00FFCBB5, 0x00F7CBAD}
	};

	// 获取内存兼容设备场景
	Mdcxp.hWnd = pCxp->hWnd;
	Mdcxp.bTransfer = TRUE;
	Mdcxp.hBitmap = NULL;
	GetMemDCXP(&Mdcxp);

	// 获取窗口大小
	GetWindowRect(pCxp->hWnd, &Rect);
	Rect.right -= Rect.left;
	Rect.bottom -= Rect.top;
	Rect.top = Rect.left = 0;

	/*if ((GetWindowLong(hWnd, GWL_STYLE) & 0x00000003) == CBS_SIMPLE)
	{
		GetWindow(hWnd, GW_CHILD);
		// 还原并释放内存设备场景
		Mdcxp.bTransfer = TRUE;
		ReleaseMemDCXP(&Mdcxp);		
	}*/

	// 绘制外框
	hHandle = (HANDLE) CreateSolidBrush(
		(pCxp->dwState & CXPS_DISABLED) ? (GetSysColor(COLOR_BTNFACE) - 0x00202020) : 0x00BD9E7B);
	FrameRect(Mdcxp.hMemDC, &Rect, (HBRUSH) hHandle);
	DeleteObject((HGDIOBJ) hHandle);

	// 绘制内框
	InflateRect(&Rect, -1, -1);
	hHandle = (HANDLE) GetSysColorBrush((pCxp->dwState & CXPS_DISABLED) ? COLOR_BTNFACE : COLOR_WINDOW);
	FrameRect(Mdcxp.hMemDC, &Rect, (HBRUSH) hHandle);

	InflateRect(&Rect, -1, -1);
	Rect.left = Rect.right - GetSystemMetrics(SM_CYVTHUMB);
	FrameRect(Mdcxp.hMemDC, &Rect, (HBRUSH) hHandle);

	Rect.left++;
	if (pCxp->dwState & CXPS_DISABLED)
		i = 0;
	else if (pCxp->dwState & CXPS_PRESSED)
		i = 1;
	else if (pCxp->dwState & CXPS_HOTLIGHT)
		i = 2;
	else
		i = 3;

	// 绘制下拉外框
	GradientRectXP(Mdcxp.hMemDC, &Rect, s_crGradientXP[i]);

	// 绘制下拉外框拐角像素
	SetPixel(Mdcxp.hMemDC, Rect.left, Rect.top, s_crGradientXP[i + 4][0]);
	SetPixel(Mdcxp.hMemDC, Rect.right - 1, Rect.top, s_crGradientXP[i + 4][1]);
	SetPixel(Mdcxp.hMemDC, Rect.left, Rect.bottom - 1, s_crGradientXP[i + 4][2]);
	SetPixel(Mdcxp.hMemDC, Rect.right - 1, Rect.bottom - 1, s_crGradientXP[i + 4][3]);		

	// 绘制下拉内框
	InflateRect(&Rect, -1, -1);
	GradientRectXP(Mdcxp.hMemDC, &Rect, s_crGradientXP[i + 8]);

	// 绘制下拉标志
	Rect.left += (Rect.right - Rect.left) / 2;
	Rect.top += (Rect.bottom - Rect.top) / 2;
	hHandle = (HANDLE) SelectObject(Mdcxp.hMemDC,
		CreatePen(PS_SOLID, 1, (pCxp->dwState & CXPS_DISABLED) ? 0x00C6CBCE : 0x0084614A));
	MoveToEx(Mdcxp.hMemDC, Rect.left - 4, Rect.top - 2, NULL);
	LineTo(Mdcxp.hMemDC, Rect.left, Rect.top + 2);
	LineTo(Mdcxp.hMemDC, Rect.left + 5, Rect.top - 3);
	MoveToEx(Mdcxp.hMemDC, Rect.left - 3, Rect.top - 2, NULL);
	LineTo(Mdcxp.hMemDC, Rect.left, Rect.top + 1);
	LineTo(Mdcxp.hMemDC, Rect.left + 4, Rect.top - 3);
	MoveToEx(Mdcxp.hMemDC, Rect.left - 3, Rect.top - 3, NULL);
	LineTo(Mdcxp.hMemDC, Rect.left, Rect.top);
	LineTo(Mdcxp.hMemDC, Rect.left + 4, Rect.top - 4);

	DeleteObject(SelectObject(Mdcxp.hMemDC, (HGDIOBJ) hHandle));

	// 还原并释放内存设备场景
	Mdcxp.bTransfer = TRUE;
	ReleaseMemDCXP(&Mdcxp);
}
////////////////////////////////////////////////////////////////////////////////////////////////////



////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus

#endif // __cplusplus
////////////////////////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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