Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: MFC
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
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")
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
=No way
Now I'm trying to detect the parrent window with Spy++, but I haven't caught it yet :(
Posted 10-Oct-12 13:12pm
Edited 10-Oct-12 17:06pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Here ID is ID_CR_EDIT, Please confirm the ID is same as that of the expected control.
GetDlgItem(ID_EDIT1) returns NULL, it means a window with ID_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.
JOHN 602 at 10-Oct-12 20:36pm
and ID_CR_EDIT is the same as it set in properties and of course it defined in Resource.h as #define ID_CR_EDIT 32784
Then I preset the text in properties window and try to read at runtime
CEdit* pBoxOne;
pBoxOne = (CEdit*) GetDlgItem(ID_CR_EDIT); in debug mode I see that is NULL
It returns NULL 'cause the prog begin searching the Edit control in same window. But what class handles Edit if it's on the ribbon panel. Looks like I should call it if I directly set the right class
I confused with all that It seems the simplest thing, but WTF ?
Santhosh_G at 10-Oct-12 20:58pm
Please use spy++ tyo find the parent and ID of the control.
JOHN 602 at 10-Oct-12 21:29pm
Ive found that window class is Afx:RibbonBar:1370000:8:10003:10
If I try do
HWND hTray;
hTray = ::FindWindow(L"Afx:RibbonBar:1360000:8:10003:10", NULL);
hTray returns NULL;
Santhosh_G at 10-Oct-12 21:33pm
This may give some information realated to Ribbon control
JOHN 602 at 10-Oct-12 22:02pm
In that articles people say that There is no way to interact directly with the controls on the ribbon( I mean there is no way to change it's state).
But a reasonable question comes to my mind: Why is there an edit control if I can't change text in it ?? It's looks like foolishly.
I deem I've tried all the ways I found to get access to the ribbon control
CString pBoxOne;
GetParentFrame()->GetDlgItemText(ID_CR_EDIT,pBoxOne);//no use
What else I should try? I don't believe that there is no way to overcome this obstacle.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 /\jmot 230
1 Zoltán Zörgő 210
2 Peter Leow 145
3 Sergey Alexandrovich Kryukov 115
4 _Asif_ 108
0 Sergey Alexandrovich Kryukov 9,353
1 OriginalGriff 6,881
2 Peter Leow 4,577
3 Zoltán Zörgő 4,129
4 Richard MacCutchan 2,882

Advertise | Privacy | Mobile
Web02 | 2.8.150129.1 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100