如果要改变Messagebox上按钮的文本和自动关闭Messagebox提示框,一种方法是自定义一个winform窗口模仿替代Messagebox,变通的实现效果,另一种方法是通过调用系统的API来实现,因为C#没有对Messagebox提供相关的关闭方法。

第一种方法(自定义winform窗口实现):

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
private extern static bool MessageBeep(uint type);
[DllImport("Shell32.dll")]
public extern static int ExtractIconEx(string libName, int iconIndex, IntPtr[] largeIcon, IntPtr[] smallIcon, int nIcons);
private IntPtr[] largeIcon;
private IntPtr[] smallIcon;
private MyMsgBox newMessageBox;
private Label frmTitle;
private Label frmMessage;
private PictureBox pIcon;
private FlowLayoutPanel flpButtons;
private Icon frmIcon;
private Button btnOK;
private Button btnAbort;
private Button btnRetry;
private Button btnIgnore;
private Button btnCancel;
private Button btnYes;
private Button btnNo;
private DialogResult CYReturnButton;
/// <summary>
/// 对话框图标
/// </summary>
public enum MyIcon
{
Error,
Explorer,
Find,
Information,
Mail,
Media,
Print,
Question,
RecycleBinEmpty,
RecycleBinFull,
Stop,
User,
Warning
}
/// <summary>
/// 对话框上的按钮
/// </summary>
public enum MyButtons
{
AbortRetryIgnore,
OK,
OKCancel,
RetryCancel,
YesNo,
YesNoCancel
}
/// <summary>
/// 绘制对话框
/// </summary>
/// <param name="title">对话框标题</param>
private void BuildMessageBox(string title)
{
newMessageBox = new MyMsgBox();
newMessageBox.Text = title;
newMessageBox.Size = new System.Drawing.Size(400, 200);
newMessageBox.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
newMessageBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
newMessageBox.Paint += new PaintEventHandler(newMessageBox_Paint);
newMessageBox.BackColor = System.Drawing.Color.White;
TableLayoutPanel tlp = new TableLayoutPanel();
tlp.RowCount = 3;
tlp.ColumnCount = 0;
tlp.Dock = System.Windows.Forms.DockStyle.Fill;
tlp.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 22));
tlp.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
tlp.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50));
tlp.BackColor = System.Drawing.Color.Transparent;
tlp.Padding = new Padding(2, 5, 2, 2);
frmTitle = new Label();
frmTitle.Dock = System.Windows.Forms.DockStyle.Fill;
frmTitle.BackColor = System.Drawing.Color.Transparent;
frmTitle.ForeColor = System.Drawing.Color.White;
frmTitle.Font = new Font("Tahoma", 9, FontStyle.Bold);
frmMessage = new Label();
frmMessage.Dock = System.Windows.Forms.DockStyle.Fill;
frmMessage.BackColor = System.Drawing.Color.White;
frmMessage.Font = new Font("Tahoma", 9, FontStyle.Regular);
frmMessage.Text = "hiii";
largeIcon = new IntPtr[250];
smallIcon = new IntPtr[250];
pIcon = new PictureBox();
ExtractIconEx("shell32.dll", 0, largeIcon, smallIcon, 250);
flpButtons = new FlowLayoutPanel();
flpButtons.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
flpButtons.Padding = new Padding(0, 5, 5, 0);
flpButtons.Dock = System.Windows.Forms.DockStyle.Fill;
flpButtons.BackColor = System.Drawing.Color.FromArgb(240, 240, 240);
TableLayoutPanel tlpMessagePanel = new TableLayoutPanel();
tlpMessagePanel.BackColor = System.Drawing.Color.White;
tlpMessagePanel.Dock = System.Windows.Forms.DockStyle.Fill;
tlpMessagePanel.ColumnCount = 2;
tlpMessagePanel.RowCount = 0;
tlpMessagePanel.Padding = new Padding(4, 5, 4, 4);
tlpMessagePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50));
tlpMessagePanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
tlpMessagePanel.Controls.Add(pIcon);
tlpMessagePanel.Controls.Add(frmMessage);
tlp.Controls.Add(frmTitle);
tlp.Controls.Add(tlpMessagePanel);
tlp.Controls.Add(flpButtons);
newMessageBox.Controls.Add(tlp);
}
/// <summary>
/// 显现对话框
/// </summary>
/// <param name="timeout">自动关闭时间,以毫秒为单位,如果设置为0则不自动关闭</param>
/// <param name="Message">对话框中显示的提示内容</param>
/// <returns></returns>
public DialogResult ShowMsg(int timeout, string Message)
{
if (timeout > 0)
{
StartTimer(timeout);
}
BuildMessageBox("");
frmMessage.Text = Message;
ShowOKButton();
newMessageBox.ShowDialog();
return CYReturnButton;
}
/// <summary>
/// 显示对话框
/// </summary>
/// <param name="timeout">自动关闭时间,以毫秒为单位,如果设置为0则不自动关闭</param>
/// <param name="Message">对话框中显示的提示内容</param>
/// <param name="Title">对话框的标题</param>
/// <returns></returns>
public DialogResult ShowMsg(int timeout, string Message, string Title)
{
if (timeout > 0)
{
StartTimer(timeout);
}
BuildMessageBox(Title);
frmTitle.Text = Title;
frmMessage.Text = Message;
ShowOKButton();
newMessageBox.ShowDialog();
return CYReturnButton;
}
/// <summary>
/// 显示对话框
/// </summary>
/// <param name="timeout">自动关闭时间,以毫秒为单位,如果设置为0则不自动关闭</param>
/// <param name="Message">对话框中显示的提示内容</param>
/// <param name="Title">对话框的标题</param>
/// <param name="MButtons">对话框中的按钮</param>
/// <returns></returns>
public DialogResult ShowMsg(int timeout, string Message, string Title, MyButtons MButtons)
{
if (timeout > 0)
{
StartTimer(timeout);
}
BuildMessageBox(Title);             
frmTitle.Text = Title;             
frmMessage.Text = Message;             
ButtonStatements(MButtons);             
newMessageBox.ShowDialog();             
return CYReturnButton;        
}
/// <summary>
/// 显示对话框
/// </summary>
/// <param name="timeout">自动关闭时间,以毫秒为单位,如果设置为0则不自动关闭</param>
/// <param name="Message">对话框中显示的提示内容</param>
/// <param name="Title">对话框的标题</param>
/// <param name="MButtons">对话框中的按钮</param>
/// <param name="MIcon">对话框中显示的图标</param>
/// <returns></returns>
public DialogResult ShowMsg(int timeout, string Message, string Title, MyButtons MButtons, MyIcon MIcon)
{
if (timeout > 0)
{
StartTimer(timeout);
}
BuildMessageBox(Title);
frmTitle.Text = Title;
frmMessage.Text = Message;
ButtonStatements(MButtons);
IconStatements(MIcon);
Image imageIcon = new Bitmap(frmIcon.ToBitmap(), 38, 38);
pIcon.Image = imageIcon;
newMessageBox.ShowDialog();
return CYReturnButton;
}
/// <summary>
/// OK按钮单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void btnOK_Click(object sender, EventArgs e)
{
CYReturnButton = DialogResult.OK;
newMessageBox.Dispose();
}
/// <summary>
/// Abort按钮单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void btnAbort_Click(object sender, EventArgs e)
{
CYReturnButton = DialogResult.Abort;
newMessageBox.Dispose();
}
/// <summary>
/// Retry按钮单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void btnRetry_Click(object sender, EventArgs e)
{
CYReturnButton = DialogResult.Retry;
newMessageBox.Dispose();
}
/// <summary>
/// Ignore按钮单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void btnIgnore_Click(object sender, EventArgs e)
{
CYReturnButton = DialogResult.Ignore;
newMessageBox.Dispose();
}
/// <summary>
/// Cancel按钮单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void btnCancel_Click(object sender, EventArgs e)
{
CYReturnButton = DialogResult.Cancel;
newMessageBox.Dispose();
}
/// <summary>
/// YSE按钮单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void btnYes_Click(object sender, EventArgs e)
{
CYReturnButton = DialogResult.Yes;
newMessageBox.Dispose();
}
/// <summary>
/// NO按钮单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void btnNo_Click(object sender, EventArgs e)
{
CYReturnButton = DialogResult.No;
newMessageBox.Dispose();
}
/// <summary>
/// OK按钮样式
/// </summary>
private void ShowOKButton()
{
btnOK = new Button();
btnOK.Text = "确定";
btnOK.Size = new System.Drawing.Size(80, 25);
btnOK.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
btnOK.Font = new Font("Tahoma", 8, FontStyle.Regular);
btnOK.Click += new EventHandler(btnOK_Click);
flpButtons.Controls.Add(btnOK);
}
/// <summary>
/// Abort按钮样式
/// </summary>
private void ShowAbortButton()
{
btnAbort = new Button();
btnAbort.Text = "中止";
btnAbort.Size = new System.Drawing.Size(80, 25);
btnAbort.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
btnAbort.Font = new Font("Tahoma", 8, FontStyle.Regular);
btnAbort.Click += new EventHandler(btnAbort_Click);
flpButtons.Controls.Add(btnAbort);
}
/// <summary>
/// Retry按钮样式
/// </summary>
private void ShowRetryButton()
{
btnRetry = new Button();
btnRetry.Text = "重试";
btnRetry.Size = new System.Drawing.Size(80, 25);
btnRetry.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
btnRetry.Font = new Font("Tahoma", 8, FontStyle.Regular);
btnRetry.Click += new EventHandler(btnRetry_Click);
flpButtons.Controls.Add(btnRetry);
}
/// <summary>
/// Ignore按钮样式
/// </summary>
private void ShowIgnoreButton()
{
btnIgnore = new Button();
btnIgnore.Text = "忽略";
btnIgnore.Size = new System.Drawing.Size(80, 25);
btnIgnore.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
btnIgnore.Font = new Font("Tahoma", 8, FontStyle.Regular);
btnIgnore.Click += new EventHandler(btnIgnore_Click);
flpButtons.Controls.Add(btnIgnore);
}
/// <summary>
/// Cancel按钮样式
/// </summary>
private void ShowCancelButton()
{
btnCancel = new Button();
btnCancel.Text = "取消";
btnCancel.Size = new System.Drawing.Size(80, 25);
btnCancel.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
btnCancel.Font = new Font("Tahoma", 8, FontStyle.Regular);
btnCancel.Click += new EventHandler(btnCancel_Click);
flpButtons.Controls.Add(btnCancel);
}
/// <summary>
/// Yes按钮样式
/// </summary>
private void ShowYesButton()
{
btnYes = new Button();
btnYes.Text = "是";
btnYes.Size = new System.Drawing.Size(80, 25);
btnYes.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
btnYes.Font = new Font("Tahoma", 8, FontStyle.Regular);
btnYes.Click += new EventHandler(btnYes_Click);
flpButtons.Controls.Add(btnYes);
}
/// <summary>
/// No按钮样式
/// </summary>
private void ShowNoButton()
{
btnNo = new Button();
btnNo.Text = "否";
btnNo.Size = new System.Drawing.Size(80, 25);
btnNo.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
btnNo.Font = new Font("Tahoma", 8, FontStyle.Regular);
btnNo.Click += new EventHandler(btnNo_Click);
flpButtons.Controls.Add(btnNo);
}
/// <summary>
/// 对话框中添加按钮
/// </summary>
/// <param name="MButtons">要添加的按钮(MyButtons枚举)</param>
private void ButtonStatements(MyButtons MButtons)
{
if (MButtons == MyButtons.AbortRetryIgnore)
{
ShowIgnoreButton();
ShowRetryButton();
ShowAbortButton();
}
if (MButtons == MyButtons.OK)
{
ShowOKButton();
}
if (MButtons == MyButtons.OKCancel)
{
ShowCancelButton();
ShowOKButton();
}
if (MButtons == MyButtons.RetryCancel)
{
ShowCancelButton();
ShowRetryButton();
}
if (MButtons == MyButtons.YesNo)
{
ShowNoButton();
ShowYesButton();
}
if (MButtons == MyButtons.YesNoCancel)
{
ShowCancelButton();
ShowNoButton();
ShowYesButton();
}
}
/// <summary>
/// 对话框中添加图标
/// </summary>
/// <param name="MIcon">要添加的图标(MyIcon枚举)</param>
private void IconStatements(MyIcon MIcon)
{
if (MIcon == MyIcon.Error)
{
MessageBeep(30);
frmIcon = Icon.FromHandle(largeIcon[109]);
}
if (MIcon == MyIcon.Explorer)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[220]);
}
if (MIcon == MyIcon.Find)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[22]);
}
if (MIcon == MyIcon.Information)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[221]);
}
if (MIcon == MyIcon.Mail)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[156]);
}
if (MIcon == MyIcon.Media)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[116]);
}
if (MIcon == MyIcon.Print)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[136]);
}
if (MIcon == MyIcon.Question)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[23]);
}
if (MIcon == MyIcon.RecycleBinEmpty)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[31]);
}
if (MIcon == MyIcon.RecycleBinFull)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[32]);
}
if (MIcon == MyIcon.Stop)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[27]);
}
if (MIcon == MyIcon.User)
{
MessageBeep(0);
frmIcon = Icon.FromHandle(largeIcon[170]);
}
if (MIcon == MyIcon.Warning)
{
MessageBeep(30);
frmIcon = Icon.FromHandle(largeIcon[217]);
}
}
void newMessageBox_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle frmTitleL = new Rectangle(0, 0, (newMessageBox.Width / 2), 22);
Rectangle frmTitleR = new Rectangle((newMessageBox.Width / 2), 0, (newMessageBox.Width / 2), 22);
Rectangle frmMessageBox = new Rectangle(0, 0, (newMessageBox.Width - 1), (newMessageBox.Height - 1));
LinearGradientBrush frmLGBL = new LinearGradientBrush(frmTitleL, Color.FromArgb(87, 148, 160), Color.FromArgb(209, 230, 243), LinearGradientMode.Horizontal);
LinearGradientBrush frmLGBR = new LinearGradientBrush(frmTitleR, Color.FromArgb(209, 230, 243), Color.FromArgb(87, 148, 160), LinearGradientMode.Horizontal);
Pen frmPen = new Pen(Color.FromArgb(63, 119, 143), 1);
g.FillRectangle(frmLGBL, frmTitleL);
g.FillRectangle(frmLGBR, frmTitleR);
g.DrawRectangle(frmPen, frmMessageBox);
}
private void StartTimer(int interval)
{
Timer timer = new Timer();
timer.Interval = interval;
timer.Tick += new EventHandler(Timer_Tick);
timer.Enabled = true;
}
private void Timer_Tick(object sender, EventArgs e)
{
newMessageBox.Close();
//停止计时器
((Timer)sender).Enabled = false;
}

第二种方法(调用API实现):

1、实现定时关闭Messagebox,通过Messagebox对话框的标题查找相应的句柄来进行关闭操作

public class MessageBoxTimeOut
{
private string _caption;
private string username;
private string pwd;
public DialogResult Show(int timeout, string text, string caption, MessageBoxButtons buttons)
{
this._caption = caption;
StartTimer(timeout);
DialogResult dr = MessageBox.Show(text, caption, buttons, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
return dr;
}
private void StartTimer(int interval)
{
Timer timer = new Timer();
timer.Interval = interval;
timer.Tick += new EventHandler(Timer_Tick);
timer.Enabled = true;
}
private void Timer_Tick(object sender, EventArgs e)
{
KillMessageBox();
//停止计时器
((Timer)sender).Enabled = false;
}
[DllImport("User32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern int PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
public const int WM_CLOSE = 0x10;
public void KillMessageBox()
{
//查找MessageBox的弹出窗口,注意对应标题
IntPtr ptr = FindWindow(null, this._caption);
if (ptr != IntPtr.Zero)
{
//查找到窗口则关闭
PostMessage(ptr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
}
}
}

2、关闭Messagebox对话框中按钮的文本文字

public class MessageBoxManager
{
private delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);
private delegate bool EnumChildProc(IntPtr hWnd, IntPtr lParam);
private const int WH_CALLWNDPROCRET = 12;
private const int WM_DESTROY = 0x0002;
private const int WM_INITDIALOG = 0x0110;
private const int WM_TIMER = 0x0113;
private const int WM_USER = 0x400;
private const int DM_GETDEFID = WM_USER + 0;
private const int MBOK = 1;
private const int MBCancel = 2;
private const int MBAbort = 3;
private const int MBRetry = 4;
private const int MBIgnore = 5;
private const int MBYes = 6;
private const int MBNo = 7;
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
private static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
[DllImport("user32.dll")]
private static extern int UnhookWindowsHookEx(IntPtr idHook);
[DllImport("user32.dll")]
private static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", EntryPoint = "GetWindowTextLengthW", CharSet = CharSet.Unicode)]
private static extern int GetWindowTextLength(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "GetWindowTextW", CharSet = CharSet.Unicode)]
private static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int maxLength);
[DllImport("user32.dll")]
private static extern int EndDialog(IntPtr hDlg, IntPtr nResult);
[DllImport("user32.dll")]
private static extern bool EnumChildWindows(IntPtr hWndParent, EnumChildProc lpEnumFunc, IntPtr lParam);
[DllImport("user32.dll", EntryPoint = "GetClassNameW", CharSet = CharSet.Unicode)]
private static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
[DllImport("user32.dll")]
private static extern int GetDlgCtrlID(IntPtr hwndCtl);
[DllImport("user32.dll")]
private static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem);
[DllImport("user32.dll", EntryPoint = "SetWindowTextW", CharSet = CharSet.Unicode)]
private static extern bool SetWindowText(IntPtr hWnd, string lpString);
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT
{
public IntPtr lResult;
public IntPtr lParam;
public IntPtr wParam;
public uint   message;
public IntPtr hwnd;
};
private static HookProc hookProc;
private static EnumChildProc enumProc;
[ThreadStatic]
private static IntPtr hHook;
[ThreadStatic]
private static int nButton;
/// <summary>
/// OK text
/// </summary>
public static string OK = "&OK";
/// <summary>
/// Cancel text
/// </summary>
public static string Cancel = "&Cancel";
/// <summary>
/// Abort text
/// </summary>
public static string Abort = "&Abort";
/// <summary>
/// Retry text
/// </summary>
public static string Retry = "&Retry";
/// <summary>
/// Ignore text
/// </summary>
public static string Ignore = "&Ignore";
/// <summary>
/// Yes text
/// </summary>
public static string Yes = "&Yes";
/// <summary>
/// No text
/// </summary>
public static string No = "&No";
static MessageBoxManager()
{
hookProc = new HookProc(MessageBoxHookProc);
enumProc = new EnumChildProc(MessageBoxEnumProc);
hHook = IntPtr.Zero;
}
public static void Register()
{
if (hHook != IntPtr.Zero)
throw new NotSupportedException("One hook per thread allowed.");
hHook = SetWindowsHookEx(WH_CALLWNDPROCRET, hookProc, IntPtr.Zero, AppDomain.GetCurrentThreadId());
}
public static void Unregister()
{
if (hHook != IntPtr.Zero)
{
UnhookWindowsHookEx(hHook);
hHook = IntPtr.Zero;
}
}
private static IntPtr MessageBoxHookProc(int nCode, IntPtr wParam, IntPtr lParam)
{
if (nCode < 0)
return CallNextHookEx(hHook, nCode, wParam, lParam);
CWPRETSTRUCT msg = (CWPRETSTRUCT)Marshal.PtrToStructure(lParam, typeof(CWPRETSTRUCT));
IntPtr hook = hHook;
if (msg.message == WM_INITDIALOG)
{
int nLength = GetWindowTextLength(msg.hwnd);
StringBuilder className = new StringBuilder(10);
GetClassName(msg.hwnd, className, className.Capacity);
if (className.ToString() == "#32770")
{
nButton = 0;
EnumChildWindows(msg.hwnd, enumProc, IntPtr.Zero);
if (nButton == 1)
{
IntPtr hButton = GetDlgItem(msg.hwnd, MBCancel);
if (hButton != IntPtr.Zero)
SetWindowText(hButton, OK);
}
}
}
return CallNextHookEx(hook, nCode, wParam, lParam);
}
private static bool MessageBoxEnumProc(IntPtr hWnd, IntPtr lParam)
{
StringBuilder className = new StringBuilder(10);
GetClassName(hWnd, className, className.Capacity);
if (className.ToString() == "Button")
{
int ctlId = GetDlgCtrlID(hWnd);
switch (ctlId)
{
case MBOK:
SetWindowText(hWnd, OK);
break;
case MBCancel:
SetWindowText(hWnd, Cancel);
break;
case MBAbort:
SetWindowText(hWnd, Abort);
break;
case MBRetry:
SetWindowText(hWnd, Retry);
break;
case MBIgnore:
SetWindowText(hWnd, Ignore);
break;
case MBYes:
SetWindowText(hWnd, Yes);
break;
case MBNo:
SetWindowText(hWnd, No);
break;
}
nButton++;
}
return true;
}
}

winform 关于Messagebox自动定时关闭和自定义提示框总按钮上文本的问题的整理相关推荐

  1. C#之windows桌面软件第五课:串口助手实现定时关闭设备、鼠标移动使按钮颜色变化功能

    本节在串口助手上实现: 1.定时关闭设备 2.移动鼠标使按钮颜色变换 Form1.cs代码如下: using System; using System.Collections.Generic; usi ...

  2. 微信小程序自定义提示框制作的简单方法

    微信小程序自定义提示框制作的简单方法 下面的时候提示框的结构 wxml部分 <!-- 提示框 --> <view class="showToast" wx:if= ...

  3. python 关闭窗口事件_PyQt5 closeEvent关闭事件退出提示框原理解析

    这篇文章主要介绍了PyQt5 closeEvent关闭事件退出提示框原理解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 如果关闭QWidget, ...

  4. 程序定时关闭器 - Windows下多功能自动定时关闭程序的软件工具

    有时您可能在程序处理复杂文档.渲染图形.下载大文件或系统升级时,无法避免地要让电脑开上几个小时.在这种情况下,一旦您的任务完成,自动结束所有活动并关闭系统的应用程序可能会非常有帮助. 程序定时关闭器是 ...

  5. Js自定义提示框(dialog版本)

    问题的来源: 开发的过程中总是要给出各种各样的提示语 ,但是每次都通过手动的形式给后面加提示感觉不舒服  又不想通过服务器控件来做这些事情. 于是就想把提示语和验证整合到一起 套在dialog上面使用 ...

  6. Flutter中自定义提示框

    1. 弹出提示框 定义模态框组件,代码如下: import 'package:flutter/material.dart'; class MyDialog extends Dialog{final S ...

  7. Qt实现侧边栏显示隐藏以及自定义提示框

    1.目的   最近在工作中需要实现一个Qt的侧边栏,通过按钮控制显示和隐藏,此外还要求实现自定义气泡提示框,最终参考网上知识进行了实现,效果如下: 1.窗口控件大小可以随窗体自由缩放: 2.侧边栏按钮 ...

  8. 自定义提示框之C#设计笔记(十一)

    一.定义提示框位置结构体 struct RECT { public int left; public int top; public int right; public int bottom; }; ...

  9. android app自动更新界面_Android自定义view之模仿登录界面文本输入框(华为云APP)...

    好久不见!!!!!,最近终于挤出时间来更新文章了,废话不多说,直接开始. 效果图如下: 01 分析 1.组合多个控件完成此输入框静态效果 2.hint值上浮下潜动画 3.一些功能 02 步骤 01 自 ...

最新文章

  1. 银联配置 linux 路径,深圳银联POS支付系统安装手册(LinuxMySQL).doc
  2. google python代码规范_如何用好python编码规范,写一手漂亮的代码
  3. 【SSH】禁用root远程、修改ssh端口
  4. linux相关函数,linux学习-信号相关函数
  5. 如何用JS实现音乐播放、暂停
  6. 过河(dp+离散化)
  7. ssm+redis 如何更简洁的利用自定义注解+AOP实现redis缓存
  8. java常用类--------枚举的基本使用
  9. 网站安全检测:8款非常有用的免费 Web 安全测试工具
  10. 星际争霸2服务器未能创建游戏,星际争霸2游戏进不去解决方法
  11. 51单片机小白零基础教程——数码管的静态显示,以及数码管拓展程序(含74HC573锁存器的介绍)
  12. android mmdd 时间问题
  13. selenium在爬虫领域的初涉(自动打开网站爬取信息)
  14. 广义表详解(C语言版)
  15. CodeForces - 140C New Year Snowmen
  16. 从零搭建若依环境(非分离版)
  17. Java 操作Word表格——创建嵌套表格、添加/复制表格行或列、设置表格是否禁止跨页断行
  18. 经典0-1背包问题(C++解决代码优化版本)
  19. leetcode find kth
  20. 什么是:产品专员、产品经理、产品总监、产品副总?

热门文章

  1. FunDA(6)- Reactive Streams:Play with Iteratees、Enumerator and Enumeratees
  2. [转载]致创业者:APP已死 服务永生
  3. 产品经理的工作感想(3)
  4. 中风患者的康复之光:间歇性θ波脉冲刺激可使中风后脑功能正常化的首次证明
  5. Windows Server 2012 重启IIS及其它IIS操作
  6. 基于人脸的常见表情识别(2)——数据获取与整理
  7. Java模板引擎StringTemplate4 - EMail模板格式化
  8. [iPhone中级] iPhone团购信息客户端的开发 (三)
  9. 苹果应用加急审核操作流程
  10. 两个网口芯片接一个变压器_RJ45端口属性及与百兆网络变压器的连接方式