我的要求是:
我正在使用基于MFC Dialog的应用程序,在这里我想用日语字符串设置对话框的标题。
以下是我的代码段:
CStringW str; // Using CStringW to support unicode characters
CTestofUTF83Dlg dlg; // CTestofUTF83Dlg is my dialog class that is derived
//from CDialog
str.LoadString(IDC_TESTJAPAN); // IDC_TESTJAPAN contains my Japanese string
SetDlgItemTextW(dlg,IDD_TESTOFUTF83_DIALOG,str); // IDD_TESTOFUTF83_DIALOG is the ID of my Dialog
使用上面的代码,对话框标题不反映日语字符串。
我认为这是由于SetDlgItemTextW的第一个参数,即对话框的句柄(dlg)。
因为,如果我使用SetDlgItemText()
功能,我可以设置标题。
请帮助我。
答案 0 :(得分:1)
是的,那不行。您尚未创建窗口/对话框,因此它没有窗口句柄(m_hWnd!= 0或垃圾)。
在CTestofUTF83Dlg的OnInitDialog()成员中调用SetWindowText。
BOOL CTestofUTF83Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// SetWindowText .... blah blah
return TRUE;
}