C# MessageBox修改

王朝c#·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

参考以下两篇文章 ,完成了在中文系统上显示英文的对话框。非常高兴,这个问题困扰了我3天之久。现在终于解决了。

主要使用技术,关键词包括:C#中使用钩子函数。

http://www.codeproject.com/cpp/dMsgBox.asp

How to change the MessageBox window

http://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");

}

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航