参考以下两篇文章 ,完成了在中文系统上显示英文的对话框。非常高兴,这个问题困扰了我3天之久。现在终于解决了。
主要使用技术,关键词包括:C#中使用钩子函数。
http://www.codeproject.com/cpp/dMsgBox.asp How to change the MessageBox windowhttp://www.codeproject.com/cs/miscctrl/MessageBoxChk.asp A "Don't show this again" checkbox for the .NET MessageBox
构造函数
public MessageBoxInternal() { // // TODO: Add constructor logic here // m_cbt = new LocalCbtHook(); m_cbt.WindowCreated += new LocalCbtHook.CbtEventHandler(WndCreated); m_cbt.WindowDestroyed += new LocalCbtHook.CbtEventHandler(WndDestroyed); m_cbt.WindowActivated += new LocalCbtHook.CbtEventHandler(WndActivated); }
private void WndCreated(object sender, CbtEventArgs e) { if (e.IsDialogWindow) { m_bInit = false; m_hwnd = e.Handle; } }
private void WndDestroyed(object sender, CbtEventArgs e) { if (e.Handle == m_hwnd) { m_bInit = false; m_hwnd = IntPtr.Zero; // if(BST_CHECKED == (int)SendMessage(m_hwndBtn,BM_GETCHECK,IntPtr.Zero,IntPtr.Zero)) // m_bCheck = true; } }
private void WndActivated(object sender, CbtEventArgs e) { if (m_hwnd != e.Handle) return;
// Not the first time if (m_bInit) return; else m_bInit = true;
if ( Thread.CurrentThread.CurrentUICulture.LCID == (new System.Globalization.CultureInfo("en-US")).LCID) { SetDlgItemText(m_hwnd, IDOK ,"&OK"); SetDlgItemText(m_hwnd, IDCANCEL ,"&Cancel"); SetDlgItemText(m_hwnd, IDABORT ,"&Abort"); SetDlgItemText(m_hwnd, IDRETRY ,"&Retry"); SetDlgItemText(m_hwnd, IDIGNORE ,"&Ignore"); SetDlgItemText(m_hwnd, IDYES ,"&Yes"); SetDlgItemText(m_hwnd, IDNO ,"&No");
复制本页网址和标题,发送给你QQ/Msn的好友一起分享
上一篇:用XMLHTTP無刷新頁面的javascript寫法
下一篇:Visual C#编程入门之表达式