Board index » cppbuilder » Getting control of clipboard insertion

Getting control of clipboard insertion


2004-09-03 05:03:59 PM
cppbuilder109
I need to be able to take control of clipboard insertion for a TMemo
and potentially a TEdit. This is so that I can perform my own Widechar
to Multibyte conversion. What I need is OnPaste for each component but
it doesn't exist.
Ideally I'd like to be able to trap WM_PASTE for a component.
--
Andrue Cope [TeamB]
[Bicester, Uk]
info.borland.com/newsgroups/guide.html
 
 

Re:Getting control of clipboard insertion

"Andrue Cope [TeamB]" < XXXX@XXXXX.COM >wrote:
Quote

[...] Ideally I'd like to be able to trap WM_PASTE for a component.
If you have subclassed the component, then you want to
override it's WndProc method:
// in the objects header (TEdit assumed)
//-------------------------------------------------------------
protected: // User declarations
virtual void __fastcall WndProc( TMessage &Message );
private: // User declarations
typedef TEdit inherited;
// in the class
//-------------------------------------------------------------
void __fastcall TMyEdit::WndProc(TMessage &Message)
{
if( Message.Msg == WM_PASTE )
{
// your custome paste code
// This message does not return a value.
}
else inherited::WndProc(Message);
}
//-------------------------------------------------------------
If you have not subclassed the component, then you want to
subclass it's WndProc method:
// in the parent form's header
//-------------------------------------------------------------
private: // User declarations
TWndMethod OldEditWndProc;
void __fastcall NewEditWndProc( TMessage& );
public: // User declarations
__fastcall TForm1::~TForm1();
// in the form's class
//-------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
OldEditWndProc = Edit1->WindowProc;
Edit1->WindowProc = NewEditWndProc;
}
//-------------------------------------------------------------
__fastcall TForm1::~TForm1()
{
Edit1->WindowProc = OldEditWndProc;
}
//-------------------------------------------------------------
void __fastcall TForm1::NewEditWndProc( TMessage &Message )
{
if( Message.Msg == WM_PASTE )
{
// your custom paste code here
}
else OldEditWndProc( Message );
}
//-------------------------------------------------------------
~ JD
 

Re:Getting control of clipboard insertion

JD wrote:
Quote
If you have not subclassed the component, then you want to
subclass it's WndProc method:
Thanks. I vaguely recalled that but wasn't able to find it in the help.
Problem sorted now.
..and may I just add that internationalising an application is even
more fun when you are going to allow the user to specify the codepage
for any operation :)
--
Andrue Cope [TeamB]
[Bicester, Uk]
info.borland.com/newsgroups/guide.html
 

{smallsort}