Print Page | Close Window

[Closed] WM_PASTE for an edit control in toolbar

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=4852
Printed Date: 23 November 2024 at 9:25am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [Closed] WM_PASTE for an edit control in toolbar
Posted By: kevins
Subject: [Closed] WM_PASTE for an edit control in toolbar
Date Posted: 22 August 2006 at 12:31pm
How do I capture WM_PASTE for an edit control in a toolbar?

We are converting our user interface to using Xtreme ToolkitPro. In our original code we have an edit box on a toolbar in which we override the WindowProc function and test the message for WM_PASTE.

How can I do this with Xtreme ToolkitPro? I have tried a few things and have failed so I am trying them again with the CustomThemes example program because it has an edit box in a toolbar. Here are the results:

I followed Olegs 2nd response to topic "Change notification for CXTPControlEdit", so now I have a control derived from CXTPControlEditCtrl. I added ON_WM_CHAR() to the message map and added the OnChar function. It gets called, that's great. But I added the WindowProc function and it never gets called. I copied the function from my existing (pre-CodeJock) code, so the function signature should be correct.

I also tried adding "ON_MESSAGE(WM_PASTE, OnPaste)" to the message map but OnPaste never gets called.


Thanks for any assistance that can be provided.



Replies:
Posted By: kevins
Date Posted: 31 August 2006 at 10:41am
Is my question unclear or am I out of luck in getting this functionality?


Posted By: Oleg
Date Posted: 31 August 2006 at 10:46am
Hi,
 
First you need to make custom edit class for CXTPControlEdit. In CustomThemes sample it is CControlComboBoxEditEx:
 
Somethinh like this:
 
class CMyEdit: public CXTPControlEditCtrl
{
public:
 DECLARE_MESSAGE_MAP()
};
 
class CControlMyEdit : public CXTPControlEdit
{
 DECLARE_XTP_CONTROL(CControlMyEdit)
public:
 virtual CXTPControlEditCtrl* CreateEditControl()
 {
  return new CMyEdit();
 }
};
 
and you will be able to catch all messages in your CMyEdit.
 


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: kevins
Date Posted: 31 August 2006 at 4:52pm
Bummer :-( That's exactly what I did. I just did a little test with CustomThemes and had no luck. It's using a combobox rather than an edit box, but hopefully the basics are the same and we can press on. I'll detail my changes here:


I added the code in Bold:

class CControlComboBoxEditEx : public CXTMaskEditT<CXTPControlComboBoxEditCtrl>
{
public:
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
LRESULT CControlComboBoxEditEx::OnPaste(WPARAM, LPARAM);

    DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP(CControlComboBoxEditEx, CXTMaskEditT<CXTPControlComboBoxEditCtrl>)
    ON_MASKEDIT_REFLECT()
    ON_WM_CREATE()
   ON_MESSAGE(WM_PASTE, OnPaste)
END_MESSAGE_MAP()

LRESULT CControlComboBoxEditEx::OnPaste(WPARAM, LPARAM)
{
   return 1; // I set a breakpoint here.
}

I pasted data into the control labeled Masked and I do not hit my breakpoint. I/We must be missing something simple. Or the control isn't getting WM_PASTE.


Posted By: kevins
Date Posted: 07 September 2006 at 10:22am
Any more ideas? I'm sure we're just missing something simple.


Posted By: Oleg
Date Posted: 07 September 2006 at 2:22pm
Hello,
Right :( Just tested it and it doesn't work.
 
The thing that Edit of combobox is actual RichEdit not standard Edit and WM_PASTE for RichEdit is not called.
 
To create standard Edit instead RichEdit just overridethis function:
 
BOOL CControlComboBoxEditEx::CreateEdit(DWORD dwStyle, CWnd* pParentWnd)
{
 return CEdit::Create(dwStyle, CRect(0, 0, 0, 0), pParentWnd, 0);
}


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: kevins
Date Posted: 15 September 2006 at 1:22pm
Thanks Oleg, I would have nevered figured that out on my own.

For anyone else reading this, here is my final routine:

BOOL ControlIntEditCtrl::CreateEdit(DWORD dwStyle, CWnd* pParentWnd)
{
   BOOL bRetVal = CEdit::Create(dwStyle, CRect(0, 0, 0, 0), pParentWnd, 0);
   // NOTE: I needed the SetWindowText to get the edit control to start with "1",
   // but after updating to CodeJock 10.3 this no longer worked. (So, I have the
   // view post a message to itself in OnInitialUpdate to get the edit box
   // initialized.)
   //pControlIntEdit->SetEditText(_T("1")); in MainFram failed to work after added this routine.
   //SetWindowText(_T("1"));
   return bRetVal;
}



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