15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Cut and Paste in CScrollView

coutop -- coutop@inf.com
Friday, January 05, 1996

     Hi,
     
     We are presently invloved in porting 16 bit MFC code to 32 bit MFC 
     code.
     
     We have a view class derived from CScrollView class. We use the view 
     as a shell  utility to type in commands at a command line and get the 
     resulting output. However we have to give a cut and paste 
     functionality too. Could someone suggest an efficient method for the 
     same. 
     
     **
     We cannot change the functionality to an extent where  we can replace 
     the CScrollView class with the CEditView class
     
     Thanks 
     
     Paul Couto
     coutop@inf.com




Mike Blaszczak -- mikeblas@interserv.com
Monday, January 08, 1996

On Fri, 05 Jan 96, "coutop"  wrote:
>     resulting output. However we have to give a cut and paste 
>     functionality too. Could someone suggest an efficient method for the 
>     same. 

This problem really comes in three pieces, if you think about it:

1) Making some way to select text in the view.  You'll need to start tracking 
the mouse when the user presses the button, and mark what they've selected as 
they move the mouse around with the button down.  When they let go of the 
button, you can stop tracking.  You need some way for your view to remember 
what is selected and what isn't.  You need to decide how selection will 
work--will the user select a simple rectangle so they can copy columns, or 
will the user select lines and lines of text (like a multiline edit control) 
so they can paste sentences and paragraphs?

2) Once you have some way for the view to remember what is selected, you need 
to have some way for the view to paint the selection.  Your paint routine 
will be called every time the mouse moves just a little during the selection 
process, so you had better make sure it is efficient.  A good way to do this 
kind of painting is with the CDC::InvertRect() function.

3) Finally, and this is the easiest part--if the user asks for the "Copy" or 
"Paste" command in the edit menu, you need to take the text that is selected 
in the view and toss it on the clipboard.  You'll probably just use CF_TEXT, 
unless you're really concerned about special formatting.  You can get a copy 
of the text and call the appropriate clipboard APIs, like SetClipboardData().

.B ekiM
--
TCHAR szDisc[] = _T("These words are my own; I do not speak for Microsoft.");





| Вернуться в корень Архива |