BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Paste data from excel to TRichEdit.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Tiago Rossi
Guest





PostPosted: Tue Mar 29, 2005 10:21 pm    Post subject: Paste data from excel to TRichEdit. Reply with quote



How can i paste data copying from excel with ctrl+c to
TRichEdit without columns information?
I need something like works "paste special" in Word. It's a way to do this
only using Clipboard?


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Mar 30, 2005 1:25 am    Post subject: Re: Paste data from excel to TRichEdit. Reply with quote




"Tiago Rossi" <tiarossi (AT) bol (DOT) com.br> wrote


Quote:
I need something like works "paste special" in Word.

You can send the EM_PASTESPECIAL message to the TRichEdit.


Gambit



Back to top
Adrian Carter
Guest





PostPosted: Thu Mar 31, 2005 12:18 pm    Post subject: Re: Paste data from excel to TRichEdit. Reply with quote



"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote

Quote:

"Tiago Rossi" <tiarossi (AT) bol (DOT) com.br> wrote in message
news:4249d4c0 (AT) newsgroups (DOT) borland.com...

I need something like works "paste special" in Word.

You can send the EM_PASTESPECIAL message to the TRichEdit.


Gambit

This posting and reply is very timely for me.
One additional question: the EM_PASTESPECIAL message should
work in my event handlers, as for "Paste" in a popup menu or a "Paste"
speedbutton. How can I also get it to work when the user presses Ctrl-V ?
I'm guessing it's something like trapping the Ctrl-V in OnKeyDown, but I'm
lost re the details of how to cancel the original paste operation.

Thanks for reading,
Adrian Carter



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Mar 31, 2005 8:14 pm    Post subject: Re: Paste data from excel to TRichEdit. Reply with quote


"Adrian Carter" <bitz (AT) bucketz (DOT) nowhere> wrote


Quote:
How can I also get it to work when the user presses Ctrl-V ?

Ctrl-V uses WM_PASTE, not EM_PASTESPECIAL. You will just have to send the
message yourself manually. Maybe assign a separate keystroke for it, ie
CTRL-SHIFT-V.


Gambit






Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Mar 31, 2005 9:12 pm    Post subject: Re: Paste data from excel to TRichEdit. Reply with quote


"Adrian Carter" <bitz (AT) bucketz (DOT) nowhere> wrote


Quote:
This posting and reply is very timely for me.
One additional question: the EM_PASTESPECIAL message should
work in my event handlers, as for "Paste" in a popup menu or a "Paste"
speedbutton. How can I also get it to work when the user presses Ctrl-V ?
I'm guessing it's something like trapping the Ctrl-V in OnKeyDown, but I'm
lost re the details of how to cancel the original paste operation.

One option would be to subclass the RichEdit to intercept the WM_PASTE
message directly. Then you can check to see which formats are available on
the clipboard, and if one of them is the Excel format that you are expecting
then you can discard the message and send EM_PASTESPECIAL instead


Gambit



Back to top
Tiago Rossi
Guest





PostPosted: Fri Apr 01, 2005 1:33 am    Post subject: Re: Paste data from excel to TRichEdit. Reply with quote


"Adrian Carter" <bitz (AT) bucketz (DOT) nowhere> wrote

Quote:
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:4249ffa2$1 (AT) newsgroups (DOT) borland.com...

"Tiago Rossi" <tiarossi (AT) bol (DOT) com.br> wrote in message
news:4249d4c0 (AT) newsgroups (DOT) borland.com...

I need something like works "paste special" in Word.

You can send the EM_PASTESPECIAL message to the TRichEdit.


Gambit

This posting and reply is very timely for me.
One additional question: the EM_PASTESPECIAL message should
work in my event handlers, as for "Paste" in a popup menu or a "Paste"
speedbutton. How can I also get it to work when the user presses Ctrl-V ?

I use EM_PASTESPECIAL and does not work well, only paste 398 lines when i
have more than 2000.

Quote:
I'm guessing it's something like trapping the Ctrl-V in OnKeyDown, but I'm
lost re the details of how to cancel the original paste operation.

I trap ctrl-v and use RitchEdit->SelText = ClipBoard()->Text; and works
fine. To cancel original
paste operation set Key = 0;

Quote:

Thanks for reading,
Adrian Carter





Back to top
Adrian Carter
Guest





PostPosted: Sat Apr 02, 2005 12:23 pm    Post subject: Re: Paste data from excel to TRichEdit. Reply with quote

Quote:
snipped

I use EM_PASTESPECIAL and does not work well, only paste 398 lines when i
have more than 2000.

I'm guessing it's something like trapping the Ctrl-V in OnKeyDown, but
I'm
lost re the details of how to cancel the original paste operation.

I trap ctrl-v and use RitchEdit->SelText = ClipBoard()->Text; and works
fine. To cancel original
paste operation set Key = 0;

Thanks Gambit, Tiago.

Subclassing the richedit worked fine for a paste via
RE->PasteFromClipboard(),
but my new WindowProc didn't see any WM_PAINT messages when I used
Ctrl-V (I logged every message, and WM_PAINT only appeared for the other
case). Subclassing is unnecessary anyway for the PasteFromClipboard() case,
because I can modify the clipboard before issuing the function call.
So I did away with the subclassing, and I now trap the Ctrl-V in OnKeyDown.
Setting Clipboard()->AsText = Clipboard()->AsText works fine, it totally
removes all formatting, which is exactly what I want (only require the text
in
tab-delimited columns). And the actual paste to the richedit doesn't happen
until
OnKeyDown finishes.

Adrian



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.