Click here to Skip to main content
13,046,533 members (71,870 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 12:12pm
Updated 10-Oct-12 16: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 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 10-Oct-12 20:58pm
Please use spy++ tyo find the parent and ID of the control.
JOHN 602 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 10-Oct-12 21:33pm
This may give some information realated to Ribbon control
JOHN 602 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2017
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