8 Replies - 698 Views - Last Post: 10 October 2012 - 07:26 PM Rate Topic: -----

#1 Shtock  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 14-November 11

Can't send the text to the Edit control

Posted 09 October 2012 - 07:15 PM

Hello dudes

I've faced with the trouble which 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"); also in vain
It is a merest trifle but
I don't see where is the problem might be

Attached image(s)

  • Attached Image

This post has been edited by Shtock: 09 October 2012 - 07:27 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Can't send the text to the Edit control

#2 snoopy11  Icon User is offline

  • Engineering ● Software
  • member icon

Reputation: 841
  • View blog
  • Posts: 2,472
  • Joined: 20-March 10

Re: Can't send the text to the Edit control

Posted 09 October 2012 - 11:46 PM

Hi,

What no code and just a picture ??

Anyway..

Sometimes the font size is too big and the text wont get displayed

Try changing the font size before sending a SetWindowText or SetDlgItemText command.

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3663
  • View blog
  • Posts: 11,482
  • Joined: 05-May 12

Re: Can't send the text to the Edit control

Posted 10 October 2012 - 03:36 AM

Quick questions:
1) Do ID_EDIT1 and ID_CR_EDIT refer to the same control?
2) Do both calls to GetDlgItem(ID_EDIT1) and GetDlgItem(ID_CR_EDIT) return valid window handles?
3) If you run Spy++, and watch the Windows messages sent to the edit control, do you see the messages being received?
Was This Post Helpful? 0
  • +
  • -

#4 Shtock  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 14-November 11

Re: Can't send the text to the Edit control

Posted 10 October 2012 - 11:50 AM

View PostSkydiver, on 10 October 2012 - 03:36 AM, said:

Quick questions:
1) Do ID_EDIT1 and ID_CR_EDIT refer to the same control?
2) Do both calls to GetDlgItem(ID_EDIT1) and GetDlgItem(ID_CR_EDIT) return valid window handles?
3) If you run Spy++, and watch the Windows messages sent to the edit control, do you see the messages being received?


Yes, I just mistyped.ID_EDIT1 and ID_CR_EDIT - it is the same control.
No, I confess to you I have never even try to work with Spy++. Okay, I'll try.
Was This Post Helpful? 0
  • +
  • -

#5 Shtock  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 14-November 11

Re: Can't send the text to the Edit control

Posted 10 October 2012 - 02:54 PM

View PostSkydiver, on 10 October 2012 - 03:36 AM, said:

Quick questions:
1) Do ID_EDIT1 and ID_CR_EDIT refer to the same control?
2) Do both calls to GetDlgItem(ID_EDIT1) and GetDlgItem(ID_CR_EDIT) return valid window handles?
3) If you run Spy++, and watch the Windows messages sent to the edit control, do you see the messages being received?

GetDlgItem(ID_EDIT1) 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

This post has been edited by Shtock: 10 October 2012 - 02:56 PM

Was This Post Helpful? 0
  • +
  • -

#6 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3663
  • View blog
  • Posts: 11,482
  • Joined: 05-May 12

Re: Can't send the text to the Edit control

Posted 10 October 2012 - 03:47 PM

View PostShtock, on 10 October 2012 - 02:54 PM, said:

GetDlgItem(ID_EDIT1) returns NULL.

That means that the context you are calling from doesn't own that window handle. It's probably nested deep within the Ribbon control rather than in your current dialog/window. This also means that all your SetDlgItemText() calls will fail because it can't find the window.

View PostShtock, on 10 October 2012 - 02:54 PM, said:

Maybe I need to catch some event in the BEGIN_MESSAGE_MAP? I don't see where the problem is.

No, it's not a matter of the message map. It's a matter of you knowing your window hierarchy and which window is the parent of that control. One way to discover the hierarchy is to use Spy++.

Basically the problem is that the Get/SetDlgItem*() framework wrapper that you are using are calling the corresponding Win32 API of the same name. The Win32 API takes as the first parameter the window that is the parent of the window being addressed. The framework that you are using is providing the current dialog or window as that parent. As you've obviously discovered, that window you are trying to address it not a child of your window. It's probably a child of the Ribbon, or even deeper down.

View PostShtock, on 10 October 2012 - 02:54 PM, said:

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.

That's the problem with drag n' drop programming without understanding what is happening under the covers. You have to know what dropping that control into the Ribbon actually means in terms of window hierarchies.

View PostShtock, on 10 October 2012 - 02:54 PM, said:

It seems to me it's quite enough to operate with Edit control, right ?

It is enough if you know what the parent window of the edit control is.
Was This Post Helpful? 0
  • +
  • -

#7 Shtock  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 14-November 11

Re: Can't send the text to the Edit control

Posted 10 October 2012 - 05:04 PM

View PostSkydiver, on 10 October 2012 - 03:47 PM, said:

View PostShtock, on 10 October 2012 - 02:54 PM, said:

GetDlgItem(ID_EDIT1) returns NULL.

That means that the context you are calling from doesn't own that window handle. It's probably nested deep within the Ribbon control rather than in your current dialog/window. This also means that all your SetDlgItemText() calls will fail because it can't find the window.

View PostShtock, on 10 October 2012 - 02:54 PM, said:

Maybe I need to catch some event in the BEGIN_MESSAGE_MAP? I don't see where the problem is.

No, it's not a matter of the message map. It's a matter of you knowing your window hierarchy and which window is the parent of that control. One way to discover the hierarchy is to use Spy++.

Basically the problem is that the Get/SetDlgItem*() framework wrapper that you are using are calling the corresponding Win32 API of the same name. The Win32 API takes as the first parameter the window that is the parent of the window being addressed. The framework that you are using is providing the current dialog or window as that parent. As you've obviously discovered, that window you are trying to address it not a child of your window. It's probably a child of the Ribbon, or even deeper down.

View PostShtock, on 10 October 2012 - 02:54 PM, said:

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.

That's the problem with drag n' drop programming without understanding what is happening under the covers. You have to know what dropping that control into the Ribbon actually means in terms of window hierarchies.

View PostShtock, on 10 October 2012 - 02:54 PM, said:

It seems to me it's quite enough to operate with Edit control, right ?

It is enough if you know what the parent window of the edit control is.


Oh..man
Your answer was so exhaustive. thanks (without any jokes)
Now I'm trying to detect what is the class where the Edit control is.
I've already tried in this way:
GetParent()->SetDlgItemText(ID_CR_EDIT,L"Abcd"); =No way
I almost got the hang of Spy++(it conflicts with VS debug mode so I run it in non-debug)
But I don't see yet what class is handling the Edit control
I try to catch parent(ribbon) window when I just set mouse over the button(without clicking) as I depicted on the picture

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#8 Shtock  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 14-November 11

Re: Can't send the text to the Edit control

Posted 10 October 2012 - 06:27 PM

View PostShtock, on 10 October 2012 - 05:04 PM, said:

View PostSkydiver, on 10 October 2012 - 03:47 PM, said:

View PostShtock, on 10 October 2012 - 02:54 PM, said:

GetDlgItem(ID_EDIT1) returns NULL.

That means that the context you are calling from doesn't own that window handle. It's probably nested deep within the Ribbon control rather than in your current dialog/window. This also means that all your SetDlgItemText() calls will fail because it can't find the window.

View PostShtock, on 10 October 2012 - 02:54 PM, said:

Maybe I need to catch some event in the BEGIN_MESSAGE_MAP? I don't see where the problem is.

No, it's not a matter of the message map. It's a matter of you knowing your window hierarchy and which window is the parent of that control. One way to discover the hierarchy is to use Spy++.

Basically the problem is that the Get/SetDlgItem*() framework wrapper that you are using are calling the corresponding Win32 API of the same name. The Win32 API takes as the first parameter the window that is the parent of the window being addressed. The framework that you are using is providing the current dialog or window as that parent. As you've obviously discovered, that window you are trying to address it not a child of your window. It's probably a child of the Ribbon, or even deeper down.

View PostShtock, on 10 October 2012 - 02:54 PM, said:

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.

That's the problem with drag n' drop programming without understanding what is happening under the covers. You have to know what dropping that control into the Ribbon actually means in terms of window hierarchies.

View PostShtock, on 10 October 2012 - 02:54 PM, said:

It seems to me it's quite enough to operate with Edit control, right ?

It is enough if you know what the parent window of the edit control is.


Oh..man
Your answer was so exhaustive. thanks (without any jokes)
Now I'm trying to detect what is the class where the Edit control is.
I've already tried in this way:
GetParent()->SetDlgItemText(ID_CR_EDIT,L"Abcd"); =No way
I almost got the hang of Spy++(it conflicts with VS debug mode so I run it in non-debug)
But I don't see yet what class is handling the Edit control
I try to catch parent(ribbon) window when I just set mouse over the button(without clicking) as I depicted on the picture

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);
if(hTray)
{

::SetDlgItemText(hTray,ID_CR_EDIT,L"mn,m");
}
hTray returns NULL;
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 3663
  • View blog
  • Posts: 11,482
  • Joined: 05-May 12

Re: Can't send the text to the Edit control

Posted 10 October 2012 - 07:26 PM

Use Spy++ to view the hierarchy tree.

You don't want to call GetParent(). You probably want something like CWindow(GetDlgItem(ID_RIBBON)).SetDlgItemText(ID_EDIT, ...) assuming that ribbon is a child of your form, and that ID_EDIT is a child of the ribbon, and that you can construct a CWindow from just a window handle with your particular framework.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1