在下一个对话框的列表框中设置字符串 [英] Set String in the List Boxes in the Next Dialog
本文介绍了在下一个对话框的列表框中设置字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好
我想在mfc和主对话框中编写一个程序,如果您单击一个按钮,我想使用
Hi
I want to write a program in mfc and in the main dialog if you click a button I want to display another dialog using
sampledlg.DoModal();
显示另一个对话框
我想在其中使用:
and in it I want to use:
listbox.AddString(L"str1");
但出现错误,我无法添加字符串.请告诉我为什么?
这是用DoModal()函数制作另一个dlg吗?
but I get an error and I can not add strings. please tell me why?
Is this for making another dlg with DoModal() function?
thanks.
推荐答案
而不是DoModal()
,如果您的初始化不存在,请尝试将其放置到虚拟BOOL OnInitDialog()
中.很久以前,我最后一次使用MFC,但是我认为在调用DoModal()
时,并不是所有的基础资源(HWND
s)都被创建,但是当InitDialog()运行时,它们已经存在了(包括您的列表框).我在启动MFC时常犯的另一个常见错误是,我没有将MFC对象附加到DoDataExchange()
和DDX_Control()
或InitDialog(
中的基础控件(HWND
s)上.SubClassDlgItem()
.
Instead ofDoModal()
try to put your initialization to virtualBOOL OnInitDialog()
if its not there already. It was long ago I used MFC for the last time but I think that at the timeDoModal()
is called not all the underlying resources (HWND
s) are created, but when InitDialog() runs, they already exist (including your listbox). Another common mistak I made a lot of times when I started MFC is that I haven''t attached the MFC objects to the underlying controls (HWND
s) in eitherDoDataExchange()
withDDX_Control()
or inInitDialog(
) withSubClassDlgItem()
.
这篇关于在下一个对话框的列表框中设置字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文