Print Page | Close Window

Change notification for CXTPControlEdit?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=1196
Printed Date: 27 April 2024 at 4:18pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Change notification for CXTPControlEdit?
Posted By: brianh
Subject: Change notification for CXTPControlEdit?
Date 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.




Replies:
Posted By: Oleg
Date 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


Posted By: brianh
Date 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



Posted By: Oleg
Date 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


Posted By: brianh
Date 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.



Posted By: Hazelnut
Date 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


Posted By: brianh
Date 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.



Posted By: Hazelnut
Date 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!



Posted By: g_j_a_i_n
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net