Board index » cppbuilder » Getting control of clipboard insertion
Andrue Cope [TeamB]
![]() CBuilder Developer |
Andrue Cope [TeamB]
![]() CBuilder Developer |
Getting control of clipboard insertion2004-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 |
JD
![]() CBuilder Developer |
2004-09-03 06:00:42 PM
Re:Getting control of clipboard insertion
"Andrue Cope [TeamB]" < XXXX@XXXXX.COM >wrote:
Quote
// 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 |
Andrue Cope [TeamB]
![]() CBuilder Developer |
2004-09-03 06:42:44 PM
Re:Getting control of clipboard insertion
JD wrote:
QuoteIf you have not subclassed the component, then you want to ..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} |