https://codebus.cn/dingyj/gui
看看这个,这个按钮函数是从上面文章解剖出来的,
/// @brief button 按钮创建函数
/// @param x1		按钮左上角 x 坐标
/// @param y1		按钮左上角 y 坐标
/// @param x2		按钮右下角 x 坐标
/// @param y2		按钮右下角 y 坐标
/// @param mouse_x	鼠标 x 座标
/// @param mouse_y	鼠标 y 座标
/// @param textsize1	鼠标没选中按钮时字体大小
/// @param textsize2	鼠标选中按钮时字体大小
/// @param button_string1	鼠标没选中按钮时显示的文本
/// @param button_string2	鼠标选中按钮时显示的文本
/// @param click_1		按钮点击特效参数: 1.启动 0.不启动
/// @return 返回一个判断按钮是否点击的参数:被点击返回 1 没有被点击返回 0
int button(int x1, int y1, int x2, int y2, int mouse_x, int mouse_y, int textsize1, int textsize2, LPCTSTR button_string1, LPCTSTR button_string2, int click_1)
{
	button_textzise(textsize1);																// 设置字体大小函数。
	setlinestyle(PS_NULL);
	setlinecolor(RGB(button_rgb2[0][0], button_rgb2[1][0], button_rgb2[2][0]));				// 设置按钮颜色的外框线体函数。
	settextcolor(WHITE);																	// 设置按钮白色的字体函数。
	setfillcolor(RGB(button_rgb1[0][0], button_rgb1[1][0], button_rgb1[2][0]));				// 使用修改颜色的 RGB 数组,可改变数组从而来自由改变颜色。
	fillroundrect(x1, y1, x2, y2, 20, 20);													// 画按钮矩形,有圆角 20,对接按钮的前四个坐标数组。
																							// 设置居中显示按钮的文字。
	outtextxy((((x2 - x1) / 2) + x1) - (textwidth(button_string1) / 2), (((y2 - y1) / 2) + y1) - (textheight(button_string1) / 2), button_string1);
	// 特制按钮,字体居中算法,不知是否比自带的效率高?但失去了一些强大的功能。
	if (mouse_x > x1 && mouse_y > y1 && mouse_x < x2 && mouse_y < y2)						// 判断鼠标是否在按钮内部,如果是就执行高亮按钮代码。
	{
		setlinestyle(PS_ENDCAP_FLAT);
		button_textzise(textsize2);															// 设置选中的按钮字体大小,产生选中字体的视觉差。
		setlinecolor(RGB(button_rgb1[0][0], button_rgb1[1][0], button_rgb1[2][0]));			// 选中按钮后把线条变颜色。
		settextcolor(WHITE);																// 选中按钮后,把文字变成白色。
		setfillcolor(RGB(button_rgb2[0][0], button_rgb2[1][0], button_rgb2[2][0]));			// 使用修改颜色的 RGB 数组,可改变数组从而来自由改变颜色。
		setbkmode(TRANSPARENT);																// 把文字背景设置成透明的。
		fillroundrect(x1, y1, x2, y2, 20, 20);												// 填充的矩形,画选中的,按钮的意思。
		outtextxy((((x2 - x1) / 2) + x1) - (textwidth(button_string2) / 2), (((y2 - y1) / 2) + y1) - (textheight(button_string2) / 2), button_string2);
		// 特制按钮,字体居中算法:按钮长度减按钮起点除一半得没有起点的一半,再加上起点得按钮宽度中心点减字符串宽度的一半得居左右中字体
		if (click_1 == 1)																	// 如果点击等于 1 就启动点击按钮特效。
		{
			settextcolor(WHITE);															// 选中按钮后,把文字变成白色。
			button_textzise(textsize2 - 3);
			fillroundrect(x1, y1, x2, y2, 20, 20);											// 填充的矩形,画选中的,按钮的意思。
																							// 在填充的矩形显示居中的高亮放大的文字。
			outtextxy((((x2 - x1) / 2) + x1) - (textwidth(button_string2) / 2), (((y2 - y1) / 2) + y1) - (textheight(button_string2) / 2), button_string2);
			// 特制按钮,字体居中算法:按钮高度减按钮高度起点除一半得没有高度起点的一半,再加上起点得按钮高度中心点减字符串疝度的一半得上下居中字体
			Sleep(100);																		// 显示按钮被点击的效果。
			settextcolor(WHITE);															// 选中按钮后,把文字变成蓝色。
			button_textzise(textsize2);
			fillroundrect(x1, y1, x2, y2, 20, 20);											// 填充的矩形,画选中的,按钮的意思。
																							// 在填充的矩形显示居中的高亮放大的文字。
			outtextxy((((x2 - x1) / 2) + x1) - (textwidth(button_string2) / 2), (((y2 - y1) / 2) + y1) - (textheight(button_string2) / 2), button_string2);
		}
		return 1;																			// 返回 1 说明,鼠标点到了该按钮,可以通过 if 函数来判断返回值 1 要干什么。
	}
	return 0;																				// 如果按钮没有被鼠标选中就返回 0。
}