Change notification for CXTPControlEdit? |
Post Reply |
Author | |
brianh
Groupie Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
Post Options
Thanks(0)
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. |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
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 |
|
brianh
Groupie Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
Post Options
Thanks(0)
|
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 |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
class CControlEditCtrl : public CXTPControlEditCtrl class CControlEdit: public CXTPControlEdit //////////////////////////////////////////////////////////// //////////////
void CControlEditCtrl::OnChanged() } |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
brianh
Groupie Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
Post Options
Thanks(0)
|
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 |
|
Hazelnut
Groupie Joined: 22 July 2005 Location: United States Status: Offline Points: 18 |
Post Options
Thanks(0)
|
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
|
|
brianh
Groupie Joined: 30 April 2004 Location: United Kingdom Status: Offline Points: 83 |
Post Options
Thanks(0)
|
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 |
|
Hazelnut
Groupie Joined: 22 July 2005 Location: United States Status: Offline Points: 18 |
Post Options
Thanks(0)
|
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! |
|
g_j_a_i_n
Groupie Joined: 27 August 2005 Status: Offline Points: 94 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |