效果图:
实现代码:
int SetMessageBoxInfo(CString parm_text, CString parm_caption,
int parm_style, int parm_icon_id)
{
MSGBOXPARAMS msg_info;
memset(&msg_info, 0, sizeof(MSGBOXPARAMS));
// 初始化结构体大小
msg_info.cbSize = sizeof(MSGBOXPARAMS);
// 拥有的窗口句柄,指定一个值
msg_info.hwndOwner = NULL;
// 如果你不使用的图标资源,并不需要明确。
msg_info.hInstance = AfxGetApp()->m_hInstance;
// 指定的文本将显示在消息框
msg_info.lpszText = parm_text;
// 消息框显示在标题指定标题的人
msg_info.lpszCaption = parm_caption;
// 消息框样式指定
msg_info.dwStyle = parm_style | MB_USERICON;
// 使用图标资源的人表示,为了使用这种说法,是一定要因素dwStyle
// MB_USERICON 你必须得到明确。
msg_info.lpszIcon = MAKEINTRESOURCE(parm_icon_id);
// 定义消息框,根据打印信息。
int result = MessageBoxIndirect(&msg_info);
// 在选定按钮的消息框的ID返回一个值。
return result;
}
按钮测试事件:
void CewwDlg::OnBnClickedButton1()
{
SetMessageBoxInfo("←自定义消息图标测试","King.Sollyu",MB_OKCANCEL, IDI_ICON1);
}
自定义按钮内容 连接:
http://blog.csdn.net/kingsollyu/article/details/6077014