如何将文本发送到“编辑"控件 [英] How to send text to the Edit control
问题描述
大家好
我遇到了将文本传输到Edit控件中的麻烦
我正在将SDI与Ribbon结合使用.编辑控件在面板上
当我尝试通过SetDlgItemText(ID_EDIT1,L"Bla-bla");从我的视图类传递文本时;
没有效果.
我已经尝试过用不同的方式做
1)
Hello guys
I''ve faced the trouble that consist in text transferring into Edit control
I''m using SDI with Ribbon. The Edit control is on the panel
When I try to pass the text from My View Class by SetDlgItemText(ID_EDIT1,L"Bla-bla");
It gives no effect.
I''ve already tried do it in different ways
1)
::SetDlgItemText(GetParent()->GetSafeHwnd(),ID_CR_EDIT,L"adasdaasd");
也是徒劳的
这是最微不足道的,但
我看不出问题可能在哪里
我把msdn和网络上的所有文章都涂成了红色,但是到处都是他们叫的
also in vain
It is the merest trifle but
I don''t see where the problem might be
I''ve red all articles on msdn and on web,But everywhere they just call
SetDlgItemText(CONTROL_ID,"Some text")
如果我尝试运行GetDlgItem(ID_EDIT1),它将返回NULL.也许我需要在BEGIN_MESSAGE_MAP中捕捉一些事件?我看不出问题出在哪里.
我从工具箱中取出Edit并将其挂在窗体上(就像我在C#中的FormConstructor中所做的那样),然后打开Properties并设置一个新ID.
在我看来,使用Edit控件就足够了,对吧?
现在,我想从MyView类中的任何函数设置新值
我认为处理Edit控件事件的父类存在问题.
我试过做
If I try run GetDlgItem(ID_EDIT1),It returns NULL. Maybe I need to catch some event in the BEGIN_MESSAGE_MAP? I don''t see where the problem is.
I took Edit from toolbox and hung it on the form(like I''d do in FormConstructor in C#), then opened Properties and set a new ID.
It seems to me it''s quite enough to operate with Edit control, right ?
Now I''d like to set a new value from whatever function in MyView class
I suppose the problem with parent class that handles Edit control events.
I''ve tried do
GetParent()->SetDlgItemText(ID_CR_EDIT,L"Abcd");
=没有办法
现在,我正在尝试使用Spy ++检测父窗口,但我还没有抓到它:(
=No way
Now I''m trying to detect the parrent window with Spy++, but I haven''t caught it yet :(
推荐答案
:: SetDlgItemText(GetParent()- > GetSafeHwnd(),ID_CR_EDIT,L"adasdaasd");
此处的ID为ID_CR_EDIT
,请确认该ID与预期控件的ID相同.
GetDlgItem(ID_EDIT1)
返回NULL,表示该窗口中不存在具有ID_EDIT1
ID的窗口.
尝试使用Spy ++工具在运行时标识父窗口和控件的ID.(从Spy菜单中,选择查找窗口",使用"Finder工具"选择您的窗口),并确保控件ID与您输入的控件ID相同.代码.请确认控件的父窗口.
::SetDlgItemText(GetParent()->GetSafeHwnd(),ID_CR_EDIT,L"adasdaasd");
Here ID isID_CR_EDIT
, Please confirm the ID is same as that of the expected control.
GetDlgItem(ID_EDIT1)
returns NULL, it means a window withID_EDIT1
ID is not exists in the window.
Try to use Spy++ tool to identify the Parent Window and ID of the control at run time.( From Spy menu, select Find Window, Use "Finder Tool" to select your window ) and ensure the control ID is same as that you given in code. Please confirm the parent window of the control too.
这篇关于如何将文本发送到“编辑"控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!