Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Change notification for CXTPControlEdit?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Change notification for CXTPControlEdit?

 Post Reply Post Reply
Author
Message
brianh View Drop Down
Groupie
Groupie


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post Topic: Change notification for CXTPControlEdit?
    Posted: 21 September 2004 at 8:45am

Hi, I have a CXTPControlEdit control in a CXTPToolBar and need to be notified when the text is changed, I tried handling the EN_CHANGE notification but this does not seem to be getting sent, can you tell me how I can get this notification message?

Thanks.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 22 September 2004 at 12:06am

You need to override CXTPControlEdit and its

CXTPControlEditCtrl* CreateEditControl()

see this technique in CustomThemes sample

(Samples\CommandBars\CustomThemes\CustomControls.h)

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
brianh View Drop Down
Groupie
Groupie


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post Posted: 22 September 2004 at 5:47am

I looked at the sample but couldn't see anywhere that was handling notifications from a CXTPControlEdit, the only override for CreateEditControl() is for a combobox and it doesn't seem to handle notifications either.

Can you give me an example of how to handle notifications from an edit control? 

Thanks

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 23 September 2004 at 1:20am

class CControlEditCtrl : public CXTPControlEditCtrl
{
 void OnChanged();
public:
 DECLARE_MESSAGE_MAP()
};

class CControlEdit: public CXTPControlEdit
{
 DECLARE_XTP_CONTROL(CControlEdit)
public:
 CXTPControlEditCtrl* CreateEditControl()
 {
  return new CControlEditCtrl();
 }
};

//////////////////////////////////////////////////////////// //////////////
//
IMPLEMENT_XTP_CONTROL(CControlEdit, CXTPControlEdit)


BEGIN_MESSAGE_MAP(CControlEditCtrl, CXTPControlEditCtrl)
 ON_CONTROL_REFLECT(EN_CHANGE, OnChanged)
END_MESSAGE_MAP()

void CControlEditCtrl::OnChanged()
{

}

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
brianh View Drop Down
Groupie
Groupie


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post Posted: 23 September 2004 at 5:13am

hmmm, I had a feeling that's what you meant - this allows the control to handle the notification itself, but I want the parent frame/view to handle it.  Do I really have to implement my own notification messages to do this?!!

If so, can you tell me where I can find the window pointer/handle for the toolbar's parent, do I use the GetParent() method to get the command bar, then it's GetOwnerSite() to get the frame pointer?

Thanks.



Edited by brianh
Back to Top
Hazelnut View Drop Down
Groupie
Groupie
Avatar

Joined: 22 July 2005
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hazelnut Quote  Post ReplyReply Direct Link To This Post Posted: 24 July 2005 at 5:18pm
Did anyone figure this out?  I'm also having problems getting the notifications from the edit control in the toobar posting to the frame window.  It really seems like this would be an important thing to have already implemented in the Control bar's framework ...unless I'm missing something here. I'm using XTP 9.70
Back to Top
brianh View Drop Down
Groupie
Groupie


Joined: 30 April 2004
Location: United Kingdom
Status: Offline
Points: 83
Post Options Post Options   Thanks (0) Thanks(0)   Quote brianh Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2005 at 3:41am

When the user hits the return key after editing, the framework sends an execute message (as though it was a button) which you can handle in the message map with:

ON_XTP_EXECUTE(ID_MYEDIT, OnMyEdit)

void CMyClass::OnMyEdit(NMHDR* pNMHDR, LRESULT* pResult)

{

NMXTPCONTROL* tagNMCONTROL = (NMXTPCONTROL*)pNMHDR;

CXTPControlEdit* pControl = (CXTPControlEdit*)tagNMCONTROL->pControl;

if (pControl->GetType() == xtpControlEdit)

{

CString str = pControl->GetEditText() ;

// do something with text

}

}

Since this is all I needed I just used this technique.  If you need more you'll have to derive your own edit control type (as Oleg shows above), intercept all the notifications using the REFLECT handlers and then send your own notification messages on to the parent/owner.  I didn't look into where you would find the owner but you can always pass it in to your control when you create it.  I think it's almost unbelievable that notifications are not already sent to the parent/owner of the controls in the toolbar (without them they're useless!), maybe they have rectified this in later versions, if not I think it's something they should seriously look into doing.



Edited by brianh
Back to Top
Hazelnut View Drop Down
Groupie
Groupie
Avatar

Joined: 22 July 2005
Location: United States
Status: Offline
Points: 18
Post Options Post Options   Thanks (0) Thanks(0)   Quote Hazelnut Quote  Post ReplyReply Direct Link To This Post Posted: 25 July 2005 at 10:12am

Hi there,

Thanks for your input and reply.  Yes, it would be very nice if they included notifications, but at this time they don't seem to. My issue is that I need to get the text from the edit control even if the user does not press the enter key.  (You know how users are!) .  At this time, I am also doing something very close to as you suggest (Thanks) and it works ...but only if the user hits enter. I need to find a way to get notifications when the text changes in the edit box. It sounds like I'm going to have to do it the hard way  I'd really like to get on with writing the application rather than trying to get the GUI to work as expected.

Anyway, Best Regards!

Back to Top
g_j_a_i_n View Drop Down
Groupie
Groupie
Avatar

Joined: 27 August 2005
Status: Offline
Points: 86
Post Options Post Options   Thanks (0) Thanks(0)   Quote g_j_a_i_n Quote  Post ReplyReply Direct Link To This Post Posted: 17 April 2006 at 9:02am


Actually,

1. I derive a class from CXTPToolBar
2. Then override the virtual function CWnd:: OnCommand() since CXTPToolBar is derived from CWnd
3. Forward all the command messages to the owner of the toolbar. The command message includes EN_CHANGE from edit control. To get the owner I use the CXTPToolBar::GetSite() function

This works for me.

Regards,
Gautam Jain
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.