How to simply COPY, PASTE with FormView 
Author Message
 How to simply COPY, PASTE with FormView

Hi,

If I make an Dialog app with a single Edit Text multiline, I can Copy or
paste text with no more code.

but....

If I make an SDI application with a FormView (a database application,
Record View) and I want to Copy or paste simple text in records, that's
does'nt work :o(  But If I place a signle Edit Text in the about box, I
can copy paste text in it.

What's wrong?  Is there a way to accept Copy or paste in my records
without manually handle it?



Thu, 28 Feb 2002 03:00:00 GMT  
 How to simply COPY, PASTE with FormView
I believe you have to implement it yourself (but I am not certain). It is
quite easy to implement as follows
1) Create menu items and accelerators for ^C^V^X. And handle as follows

void xxxx::OnEditCopy()
{
 if( GetSelectedEdit() )
  GetSelectedEdit()->Copy();

Quote:
}

void xxxx::OnEditCut()
{
 if( GetSelectedEdit() )
  GetSelectedEdit()->Cut();
Quote:
}

void xxxx::OnEditPaste()
{
 if( GetSelectedEdit() )
  GetSelectedEdit()->Paste();

Quote:
}

2) Add a function to determine which edit is selected. This is not a very
good example but does demonstrate one method.

////////////////////////////////////////////////////////////////////////////
///
//DESCRIPTION:
// Determine which exit box is selected.
//CREATED:
// 15-7-1999  10:53:47
//PARAMS:
//
//RETURN:
// Pointer to selected edit or NULL for none selected
CEdit* xxxx::GetSelectedEdit()
{
 if( &m_edtSearch == GetFocus() )
  return &m_edtSearch;
 if( &m_edtAlarmNo == GetFocus() )
  return &m_edtAlarmNo;
 if( &m_edtName == GetFocus() )
  return &m_edtName;
 return NULL;

Quote:
}

This is not very generic and prone to errors. You would be better off doing
something like

CWnd *pEdit = GetFocus() ;
then check if is derived from a CEdit with the following
 if(pEdit ->IsKindOf(RUNTIME_CLASS(CEdit)))  ... blar blar blar....

Good luck.

--
John McTainsh
______________________________________________
If you have a comment regarding my answer , please mail

Just another solution from New Zealand.

Quote:

>Hi,

>If I make an Dialog app with a single Edit Text multiline, I can Copy or
>paste text with no more code.

>but....

>If I make an SDI application with a FormView (a database application,
>Record View) and I want to Copy or paste simple text in records, that's
>does'nt work :o(  But If I place a signle Edit Text in the about box, I
>can copy paste text in it.

>What's wrong?  Is there a way to accept Copy or paste in my records
>without manually handle it?



Fri, 01 Mar 2002 03:00:00 GMT  
 How to simply COPY, PASTE with FormView

Quote:

> If I make an SDI application with a FormView (a database application,
> Record View) and I want to Copy or paste simple text in records, that's
> does'nt work :o(  But If I place a signle Edit Text in the about box, I
> can copy paste text in it.

The component gallery will add the code for you.  Look under:

Project | Add to Project | Components and Controls,

Then choose Visual C++ Components and look for the Clipboard Assistant.

Jim [VC/MFC MVP]
To send mail, change spam-me-not to msn



Fri, 01 Mar 2002 03:00:00 GMT  
 How to simply COPY, PASTE with FormView
Try the following:

Add a handler for "PreTranslateMessage()" in your
View class, then add a call to "IsDialogMessage()"
and voila... Cut and Paste workes again.

*
* BOOL CIniView::PreTranslateMessage(MSG* pMsg)
* {
*  if (IsDialogMessage(pMsg))
*  {
*    return(TRUE);
*  }
*
*  return CFormView::PreTranslateMessage(pMsg);
* }
*

/Per



Quote:
> Hi,

> If I make an Dialog app with a single Edit Text multiline, I can Copy or
> paste text with no more code.

> but....

> If I make an SDI application with a FormView (a database application,
> Record View) and I want to Copy or paste simple text in records, that's
> does'nt work :o(  But If I place a signle Edit Text in the about box, I
> can copy paste text in it.

> What's wrong?  Is there a way to accept Copy or paste in my records
> without manually handle it?



Sat, 02 Mar 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Copy/Paste via keyboard not working in FormView

2. cut & paste on a FormView

3. Menus--Update Cut/Copy/Paste Status

4. Clipboard - Copy & Paste

5. Hmm copy and paste quandry - beyond the Clipboard

6. RTF copy & paste problem

7. Cut, Copy, Paste, Insert Datagrid items

8. How to copy/paste tables between mdb files ?

9. Selection, copy/paste from keyboard

10. copy paste disabled by autocomplete in sample.dsm

11. Inheriting a class without copying and pasting a lot

12. copy and paste problem

 

 
Powered by phpBB® Forum Software