EDN Admin
Well-known member
Hi
I am using clipboard to copy line object or curve to it and then paste it
but when I try ti do the paste nothing get pasted and I do not why
could you please tell me how I can fix it
and is my implementation in the paste to distinguish if line or curve is in the clipboard using IsClipboardFormatAvailable right ??
<pre class="prettyprint void Cpatron1View::copyout1(void)
{
////////////////////
if(OpenClipboard()){
EmptyClipboard();
Cpatron1Doc *doc = GetDocument();
if(doc->sel ==true && doc->selind!=-1){
doc->selcurve=false;
doc->SetModifiedFlag();
format = RegisterClipboardFormat("myline");
doc->copyline2=new Line();
doc->copyline2->start.x=doc->mylines[doc->selind]->start.x;
doc->copyline2->start.y=doc->mylines[doc->selind]->start.y;
doc->copyline2->end.x=doc->mylines[doc->selind]->end.x;
doc->SetModifiedFlag();
doc->copyline2->end.y=doc->mylines[doc->selind]->end.y;
doc->copyline2->color=doc->mylines[doc->selind]->color;
doc->copyline2->type=doc->mylines[doc->selind]->type;
doc->copyline2->bensa =doc->mylines[doc->selind]->bensa;
doc->SetModifiedFlag();
doc->copyline2->basic =doc->mylines[doc->selind]->basic;
doc->copyline2->intpoint=doc->mylines[doc->selind]->intpoint;
doc->SetModifiedFlag();
doc->copyline2->cut=doc->mylines[doc->selind]->cut;
doc->copyline2->selcut=doc->mylines[doc->selind]->selcut;
doc->copyline2->cutdirect=doc->mylines[doc->selind]->cutdirect;
doc->copyline2->style=doc->mylines[doc->selind]->style;
doc->SetModifiedFlag();
//allocate some global memory
HGLOBAL clipbuffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, sizeof(Line)*2);
Line* buffer = (Line*)GlobalLock(clipbuffer);
//put the data into that memory
buffer = doc->copyline2;
///////////////////////
/*buffer->color = doc->copyline2 ->color;
buffer->style = doc->copyline2 ->style;
buffer->cut = doc->copyline2 ->cut;
buffer->bensa = doc->copyline2 ->bensa;
buffer->start = doc->copyline2 ->start;
buffer->end = doc->copyline2 ->end;
buffer->isaddition = doc->copyline2 ->isaddition;*/
//////////////////////
//put it on the clipboard
GlobalUnlock(clipbuffer);
SetClipboardData(format,clipbuffer);
}
CloseClipboard();
}
}//copyout1[/code]
<br/>
<pre class="prettyprint void Cpatron1View::OnPasteOut()
{
Cpatron1Doc *doc = GetDocument();
format = RegisterClipboardFormat("myline");
////////////////////
if ( OpenClipboard() )
{
//get the buffer
HANDLE hData = GetClipboardData(format);
Line* buffer = (Line*)GlobalLock( hData );
//make a local copy
doc->copyline2=new Line();
/////////////////////////////////
doc->copyline2->start.x= buffer->start.x;
doc->copyline2->start.y= buffer->start.y;
doc->copyline2->end.x=buffer->end.x;
doc->SetModifiedFlag();
doc->copyline2->end.y=buffer->end.y;
doc->copyline2->color=buffer->color;
doc->copyline2->type=buffer->type;
doc->copyline2->bensa =buffer->bensa;
doc->SetModifiedFlag();
doc->copyline2->basic =buffer->basic;
doc->copyline2->intpoint=buffer->intpoint;
doc->SetModifiedFlag();
doc->copyline2->cut=buffer->cut;
doc->copyline2->selcut=buffer->selcut;
doc->copyline2->cutdirect=buffer->cutdirect;
doc->copyline2->style=buffer->style;
doc->SetModifiedFlag();
//////////////////////////////
GlobalUnlock( hData );
CloseClipboard();
if(doc->copyline2 != NULL){
doc->pasteline2=new Line();
doc->pasteline2->color = doc->copyline2->color;
doc->pasteline2->type = doc->copyline2->type;
doc->pasteline2->bensa = doc->copyline2->bensa;
doc->pasteline2->basic = doc->copyline2->basic;
doc->pasteline2->intpoint = doc->copyline2->intpoint;
doc->pasteline2->cut = doc->copyline2->cut;
doc->pasteline2->selcut = doc->copyline2->selcut;
doc->SetModifiedFlag();
doc->pasteline2->cutdirect = doc->copyline2->cutdirect;
doc-> pasteline2->style = doc->copyline2->style;
doc->SetModifiedFlag();
doc->pasteline2->start.x=doc->copyline2->start.x+50;
doc->pasteline2->start.y=doc->copyline2->start.y-50;
doc->copyline2->start.x=doc->copyline2->start.x+50;
doc->copyline2->start.y=doc->copyline2->start.y-50;
doc->pasteline2->end.x= doc->copyline2->end.x+50;
doc->pasteline2->end.y= doc->copyline2->end.y-50;
doc->copyline2->end.x= doc->copyline2->end.x+50;
doc->copyline2->end.y= doc->copyline2->end.y-50;
doc->SetModifiedFlag();
doc->mylines.Add(doc->pasteline2);
doc->mylines.FreeExtra();
doc->SetModifiedFlag();
Invalidate();
}
}//my line fromat
/*
else if ( IsClipboardFormatAvailable(format2) ){
//get the buffer
HANDLE hData = GetClipboardData(format2);
Curve * buffer2 = (Curve *)GlobalLock( hData );
//make a local copy
doc->copycurve2=new Curve();
/////////////////////////////////
doc->copycurve2->color= buffer2->color;
doc->copycurve2->type=buffer2->type;
doc->copycurve2->style=buffer2->style;
doc->SetModifiedFlag();
doc->copycurve2->cp=buffer2->cp;
doc->copycurve2->cut=buffer2->cut;
doc->copycurve2->selcut=buffer2->selcut;
doc->SetModifiedFlag();
doc->copycurve2->cpoint[0].x=buffer2->cpoint[0].x;
doc->copycurve2->cpoint[0].y=buffer2->cpoint[0].y;
doc->copycurve2->cpoint[1].x=buffer2->cpoint[1].x;
doc->SetModifiedFlag();
doc->copycurve2->cpoint[1].y=buffer2->cpoint[1].y;
doc->copycurve2->cpoint[2].x=buffer2->cpoint[2].x;
doc->copycurve2->cpoint[2].y=buffer2->cpoint[2].y;
doc->copycurve2->cpoint[3].x=buffer2->cpoint[3].x;
doc->copycurve2->cpoint[3].y=buffer2->cpoint[3].y;
doc->SetModifiedFlag();
/////////////////////////////////
GlobalUnlock( hData );
CloseClipboard();
if(doc->copycurve2 != NULL){
doc->pastecurve2=new Curve();
doc-> pastecurve2->color=doc->copycurve2->color;
doc->pastecurve2->type=doc->copycurve2->type;
doc->pastecurve2->style=doc->copycurve2->style;
doc->pastecurve2->cp=doc->copycurve2->cp;
doc->SetModifiedFlag();
doc->pastecurve2->cut=doc->copycurve2->cut;
doc->pastecurve2->selcut=doc->copycurve2->selcut;
doc->SetModifiedFlag();
doc->pastecurve2->cpoint[0].x=doc->copycurve2->cpoint[0].x+50;
doc->pastecurve2->cpoint[0].y=doc->copycurve2->cpoint[0].y-50;
doc->pastecurve2->cpoint[1].x=doc->copycurve2->cpoint[1].x+50;
doc->pastecurve2->cpoint[1].y=doc->copycurve2->cpoint[1].y-50;
doc->pastecurve2->cpoint[2].x=doc->copycurve2->cpoint[2].x+50;
doc->pastecurve2->cpoint[2].y=doc->copycurve2->cpoint[2].y-50;
doc->pastecurve2->cpoint[3].x=doc->copycurve2->cpoint[3].x+50;
doc->pastecurve2->cpoint[3].y=doc->copycurve2->cpoint[3].y-50;
doc->SetModifiedFlag();
doc->mycurves.Add(doc->pastecurve2);
doc->mycurves.FreeExtra();
doc->SetModifiedFlag();
Invalidate();
}// doc->copycurve2 != NULL
}//curve format
*/
///////////////////////////////////
}//paste out[/code]
<br/>
Another thing how I can copy many lines and curves at the same time instead of one object at each time ??
I am using visual studio 2010 c++ MFC
Thanks a lot
View the full article
I am using clipboard to copy line object or curve to it and then paste it
but when I try ti do the paste nothing get pasted and I do not why
could you please tell me how I can fix it
and is my implementation in the paste to distinguish if line or curve is in the clipboard using IsClipboardFormatAvailable right ??
<pre class="prettyprint void Cpatron1View::copyout1(void)
{
////////////////////
if(OpenClipboard()){
EmptyClipboard();
Cpatron1Doc *doc = GetDocument();
if(doc->sel ==true && doc->selind!=-1){
doc->selcurve=false;
doc->SetModifiedFlag();
format = RegisterClipboardFormat("myline");
doc->copyline2=new Line();
doc->copyline2->start.x=doc->mylines[doc->selind]->start.x;
doc->copyline2->start.y=doc->mylines[doc->selind]->start.y;
doc->copyline2->end.x=doc->mylines[doc->selind]->end.x;
doc->SetModifiedFlag();
doc->copyline2->end.y=doc->mylines[doc->selind]->end.y;
doc->copyline2->color=doc->mylines[doc->selind]->color;
doc->copyline2->type=doc->mylines[doc->selind]->type;
doc->copyline2->bensa =doc->mylines[doc->selind]->bensa;
doc->SetModifiedFlag();
doc->copyline2->basic =doc->mylines[doc->selind]->basic;
doc->copyline2->intpoint=doc->mylines[doc->selind]->intpoint;
doc->SetModifiedFlag();
doc->copyline2->cut=doc->mylines[doc->selind]->cut;
doc->copyline2->selcut=doc->mylines[doc->selind]->selcut;
doc->copyline2->cutdirect=doc->mylines[doc->selind]->cutdirect;
doc->copyline2->style=doc->mylines[doc->selind]->style;
doc->SetModifiedFlag();
//allocate some global memory
HGLOBAL clipbuffer;
EmptyClipboard();
clipbuffer = GlobalAlloc(GMEM_DDESHARE, sizeof(Line)*2);
Line* buffer = (Line*)GlobalLock(clipbuffer);
//put the data into that memory
buffer = doc->copyline2;
///////////////////////
/*buffer->color = doc->copyline2 ->color;
buffer->style = doc->copyline2 ->style;
buffer->cut = doc->copyline2 ->cut;
buffer->bensa = doc->copyline2 ->bensa;
buffer->start = doc->copyline2 ->start;
buffer->end = doc->copyline2 ->end;
buffer->isaddition = doc->copyline2 ->isaddition;*/
//////////////////////
//put it on the clipboard
GlobalUnlock(clipbuffer);
SetClipboardData(format,clipbuffer);
}
CloseClipboard();
}
}//copyout1[/code]
<br/>
<pre class="prettyprint void Cpatron1View::OnPasteOut()
{
Cpatron1Doc *doc = GetDocument();
format = RegisterClipboardFormat("myline");
////////////////////
if ( OpenClipboard() )
{
//get the buffer
HANDLE hData = GetClipboardData(format);
Line* buffer = (Line*)GlobalLock( hData );
//make a local copy
doc->copyline2=new Line();
/////////////////////////////////
doc->copyline2->start.x= buffer->start.x;
doc->copyline2->start.y= buffer->start.y;
doc->copyline2->end.x=buffer->end.x;
doc->SetModifiedFlag();
doc->copyline2->end.y=buffer->end.y;
doc->copyline2->color=buffer->color;
doc->copyline2->type=buffer->type;
doc->copyline2->bensa =buffer->bensa;
doc->SetModifiedFlag();
doc->copyline2->basic =buffer->basic;
doc->copyline2->intpoint=buffer->intpoint;
doc->SetModifiedFlag();
doc->copyline2->cut=buffer->cut;
doc->copyline2->selcut=buffer->selcut;
doc->copyline2->cutdirect=buffer->cutdirect;
doc->copyline2->style=buffer->style;
doc->SetModifiedFlag();
//////////////////////////////
GlobalUnlock( hData );
CloseClipboard();
if(doc->copyline2 != NULL){
doc->pasteline2=new Line();
doc->pasteline2->color = doc->copyline2->color;
doc->pasteline2->type = doc->copyline2->type;
doc->pasteline2->bensa = doc->copyline2->bensa;
doc->pasteline2->basic = doc->copyline2->basic;
doc->pasteline2->intpoint = doc->copyline2->intpoint;
doc->pasteline2->cut = doc->copyline2->cut;
doc->pasteline2->selcut = doc->copyline2->selcut;
doc->SetModifiedFlag();
doc->pasteline2->cutdirect = doc->copyline2->cutdirect;
doc-> pasteline2->style = doc->copyline2->style;
doc->SetModifiedFlag();
doc->pasteline2->start.x=doc->copyline2->start.x+50;
doc->pasteline2->start.y=doc->copyline2->start.y-50;
doc->copyline2->start.x=doc->copyline2->start.x+50;
doc->copyline2->start.y=doc->copyline2->start.y-50;
doc->pasteline2->end.x= doc->copyline2->end.x+50;
doc->pasteline2->end.y= doc->copyline2->end.y-50;
doc->copyline2->end.x= doc->copyline2->end.x+50;
doc->copyline2->end.y= doc->copyline2->end.y-50;
doc->SetModifiedFlag();
doc->mylines.Add(doc->pasteline2);
doc->mylines.FreeExtra();
doc->SetModifiedFlag();
Invalidate();
}
}//my line fromat
/*
else if ( IsClipboardFormatAvailable(format2) ){
//get the buffer
HANDLE hData = GetClipboardData(format2);
Curve * buffer2 = (Curve *)GlobalLock( hData );
//make a local copy
doc->copycurve2=new Curve();
/////////////////////////////////
doc->copycurve2->color= buffer2->color;
doc->copycurve2->type=buffer2->type;
doc->copycurve2->style=buffer2->style;
doc->SetModifiedFlag();
doc->copycurve2->cp=buffer2->cp;
doc->copycurve2->cut=buffer2->cut;
doc->copycurve2->selcut=buffer2->selcut;
doc->SetModifiedFlag();
doc->copycurve2->cpoint[0].x=buffer2->cpoint[0].x;
doc->copycurve2->cpoint[0].y=buffer2->cpoint[0].y;
doc->copycurve2->cpoint[1].x=buffer2->cpoint[1].x;
doc->SetModifiedFlag();
doc->copycurve2->cpoint[1].y=buffer2->cpoint[1].y;
doc->copycurve2->cpoint[2].x=buffer2->cpoint[2].x;
doc->copycurve2->cpoint[2].y=buffer2->cpoint[2].y;
doc->copycurve2->cpoint[3].x=buffer2->cpoint[3].x;
doc->copycurve2->cpoint[3].y=buffer2->cpoint[3].y;
doc->SetModifiedFlag();
/////////////////////////////////
GlobalUnlock( hData );
CloseClipboard();
if(doc->copycurve2 != NULL){
doc->pastecurve2=new Curve();
doc-> pastecurve2->color=doc->copycurve2->color;
doc->pastecurve2->type=doc->copycurve2->type;
doc->pastecurve2->style=doc->copycurve2->style;
doc->pastecurve2->cp=doc->copycurve2->cp;
doc->SetModifiedFlag();
doc->pastecurve2->cut=doc->copycurve2->cut;
doc->pastecurve2->selcut=doc->copycurve2->selcut;
doc->SetModifiedFlag();
doc->pastecurve2->cpoint[0].x=doc->copycurve2->cpoint[0].x+50;
doc->pastecurve2->cpoint[0].y=doc->copycurve2->cpoint[0].y-50;
doc->pastecurve2->cpoint[1].x=doc->copycurve2->cpoint[1].x+50;
doc->pastecurve2->cpoint[1].y=doc->copycurve2->cpoint[1].y-50;
doc->pastecurve2->cpoint[2].x=doc->copycurve2->cpoint[2].x+50;
doc->pastecurve2->cpoint[2].y=doc->copycurve2->cpoint[2].y-50;
doc->pastecurve2->cpoint[3].x=doc->copycurve2->cpoint[3].x+50;
doc->pastecurve2->cpoint[3].y=doc->copycurve2->cpoint[3].y-50;
doc->SetModifiedFlag();
doc->mycurves.Add(doc->pastecurve2);
doc->mycurves.FreeExtra();
doc->SetModifiedFlag();
Invalidate();
}// doc->copycurve2 != NULL
}//curve format
*/
///////////////////////////////////
}//paste out[/code]
<br/>
Another thing how I can copy many lines and curves at the same time instead of one object at each time ??
I am using visual studio 2010 c++ MFC
Thanks a lot
View the full article