Click here to Skip to main content
15,881,715 members

How to send text to the Edit control

JOHN 602 asked:

Open original thread
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)
C++
::SetDlgItemText(GetParent()->GetSafeHwnd(),ID_CR_EDIT,L"adasdaasd");

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
C++
SetDlgItemText(CONTROL_ID,"Some text")


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
C++
GetParent()->SetDlgItemText(ID_CR_EDIT,L"Abcd");
=No way
Now I'm trying to detect the parrent window with Spy++, but I haven't caught it yet :(
Tags: MFC

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900