如何更改messageboxbutton消息框按钮的名称 就是自己新建立一个窗体,然后自己在上面画几个BUTTON.要用的时候就弹出来.很简单.消息框跟普通窗体没区别。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 哈哈,就是自己建立一个form,比如叫做form5,在form5上放你想要的按钮如“重试”写成“再来一次”,然后当点击这个按钮时:this.DiologResult=DiologResult.OK (好像英文拼写不太对,反正就是这个意思,呵呵)在你要调用这个所谓信息框的界面中:form5 f5 =new form5;f5.ShowDiolog();就可以了。要判断是否按钮被点击,只要判断:if (f5.DiologResult==DiologResult.OK) \\注意判断中用==,而不要写成= .....不知道说清楚了么,(好像英文拼写不太对,反正就是这个意思,再次,呵呵) 通过截获消息实现,参考如下代码:public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);[DllImport("user32.dll")]public static extern IntPtr SetWindowsHookEx(int hookid, HookProc pfnhook, IntPtr hinst, int threadid);[DllImport("user32.dll")]public static extern IntPtr CallNextHookEx(IntPtr hhook, int code, IntPtr wparam, IntPtr lparam);[DllImport("kernel32.dll")]public static extern IntPtr GetModuleHandle(string modName);[DllImport("user32.dll")]public static extern bool UnhookWindowsHookEx(IntPtr hhook);public const int WH_CBT = 5;public const int HCBT_ACTIVATE = 5;IntPtr hookHandle = IntPtr.Zero;public delegate bool WNDENUMPROC(IntPtr hwnd, int lParam);[DllImport("user32.dll")]public static extern int EnumChildWindows(IntPtr hWndParent, WNDENUMPROC lpEnumFunc, int lParam);[DllImport("user32.dll")]public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);[DllImport("user32.dll")]public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);[DllImport("user32.dll")]public static extern void SetWindowText(IntPtr hwnd, string lpString);public bool EnumChild(IntPtr hwnd, int lParam){ StringBuilder vBuffer = new StringBuilder(256); GetClassName(hwnd, vBuffer, vBuffer.Capacity); if (vBuffer.ToString().ToLower() == "button") // 按钮 { StringBuilder vText = new StringBuilder(256); GetWindowText(hwnd, vText, vText.Capacity); if (vText.ToString().ToLower().IndexOf("&a") >= 0) // 终止 SetWindowText(hwnd, "停不要动"); if (vText.ToString().ToLower().IndexOf("&r") >= 0) // 重试 SetWindowText(hwnd, "再来一次"); if (vText.ToString().ToLower().IndexOf("&i") >= 0) // 忽略 SetWindowText(hwnd, "就这样吧"); } return true;}private IntPtr CBTHookCallback(int nCode, IntPtr wParam, IntPtr lParam){ switch (nCode) { case HCBT_ACTIVATE: EnumChildWindows(wParam, new WNDENUMPROC(EnumChild), 0); UnhookWindowsHookEx(hookHandle); break; } return CallNextHookEx(hookHandle, nCode, wParam, lParam);}private void button1_Click(object sender, EventArgs e){ hookHandle = SetWindowsHookEx(WH_CBT, new HookProc(CBTHookCallback), GetModuleHandle(null), 0); MessageBox.Show("Zswang 路过", "提示", MessageBoxButtons.AbortRetryIgnore);}再蹭点分 C# URL编码函数 C#正则问题,正则网页代码 为什么发送邮件不成功 listview中如何通过嵌入checkbox以选中选择数据行? c#导出EXCEL中的统计图(char)的代码 请教C#中读取这种文件格式方法 弹出窗体的内存回收机制 正则表达式匹配的问题! 求正则表达式 很菜的送分题,在C#中怎么使用RegisterHotKey? 我做了个打印界面,想再点击按钮保存的过后,让这个按钮不再可用,避免2次保存? C#.net按钮问题,急!谢谢!
就是自己建立一个form,比如叫做form5,在form5上放你想要的按钮如“重试”写成“再来一次”,然后当点击这个按钮时:
this.DiologResult=DiologResult.OK (好像英文拼写不太对,反正就是这个意思,呵呵)在你要调用这个所谓信息框的界面中:
form5 f5 =new form5;
f5.ShowDiolog();就可以了。
要判断是否按钮被点击,只要判断:
if (f5.DiologResult==DiologResult.OK) \\注意判断中用==,而不要写成=
.....不知道说清楚了么,(好像英文拼写不太对,反正就是这个意思,再次,呵呵)
public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);[DllImport("user32.dll")]
public static extern IntPtr SetWindowsHookEx(int hookid,
HookProc pfnhook, IntPtr hinst, int threadid);[DllImport("user32.dll")]
public static extern IntPtr CallNextHookEx(IntPtr hhook,
int code, IntPtr wparam, IntPtr lparam);[DllImport("kernel32.dll")]
public static extern IntPtr GetModuleHandle(string modName);[DllImport("user32.dll")]
public static extern bool UnhookWindowsHookEx(IntPtr hhook);public const int WH_CBT = 5;
public const int HCBT_ACTIVATE = 5;
IntPtr hookHandle = IntPtr.Zero;public delegate bool WNDENUMPROC(IntPtr hwnd, int lParam);[DllImport("user32.dll")]
public static extern int EnumChildWindows(IntPtr hWndParent,
WNDENUMPROC lpEnumFunc, int lParam);[DllImport("user32.dll")]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName,
int nMaxCount);[DllImport("user32.dll")]
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString,
int nMaxCount);[DllImport("user32.dll")]
public static extern void SetWindowText(IntPtr hwnd, string lpString);public bool EnumChild(IntPtr hwnd, int lParam)
{
StringBuilder vBuffer = new StringBuilder(256);
GetClassName(hwnd, vBuffer, vBuffer.Capacity);
if (vBuffer.ToString().ToLower() == "button") // 按钮
{
StringBuilder vText = new StringBuilder(256);
GetWindowText(hwnd, vText, vText.Capacity);
if (vText.ToString().ToLower().IndexOf("&a") >= 0) // 终止
SetWindowText(hwnd, "停不要动");
if (vText.ToString().ToLower().IndexOf("&r") >= 0) // 重试
SetWindowText(hwnd, "再来一次");
if (vText.ToString().ToLower().IndexOf("&i") >= 0) // 忽略
SetWindowText(hwnd, "就这样吧");
}
return true;
}private IntPtr CBTHookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
switch (nCode)
{
case HCBT_ACTIVATE:
EnumChildWindows(wParam, new WNDENUMPROC(EnumChild), 0);
UnhookWindowsHookEx(hookHandle);
break;
}
return CallNextHookEx(hookHandle, nCode, wParam, lParam);
}
private void button1_Click(object sender, EventArgs e)
{
hookHandle = SetWindowsHookEx(WH_CBT, new HookProc(CBTHookCallback),
GetModuleHandle(null), 0);
MessageBox.Show("Zswang 路过", "提示", MessageBoxButtons.AbortRetryIgnore);
}
再蹭点分