Copy/Paste

Gary Woodley
Posts: 28
Joined: Mon Apr 27, 2009 3:37 pm
Location: Oxford UK

Copy/Paste

Post by Gary Woodley »

We have found a problem, where copy/paste does not work correctly if copying from one get to another, unless the get we are pasting to is a multiline get. We have testing this on an older version(10.06) of fivewin and works fine. When you paste it looks like only the first letter is pasted.

Any suggestions?

Regards
Gary
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Copy/Paste

Post by anserkk »

Here copy paste is working fine. Tested with FWH ver 11.09

Code: Select all

#include "FiveWin.ch"
Function Main()

    Local oDlg,oGet1,oGet2,cVar1:=Space(30),cVar2:=space(30)
    
    DEFINE DIALOG oDlg TITLE "Testing Copy Paste"
    
        @01,01 GET oGet1 VAR cVar1 SIZE 100,12
        @03,01 GET oGet2 VAR cVar2 SIZE 100,12
    
    ACTIVATE DIALOG oDlg
     
Return nil
Regards
Anser
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Copy/Paste

Post by PeterHarmes »

Could this be a xHarbour.com & FWH 11.09 compatability issue?

Can anyone tell me the source code to check for differences between FW versions and also put debug statements in?

best regards,

Pete
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: Copy/Paste

Post by Richard Chidiak »

If you are using resources make sure the field you want to paste to has ES_AUTOHSCROLL

CONTROL "", 208, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 54, 3, 70, 12 as an example

Hth

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Copy/Paste

Post by PeterHarmes »

The field I just tested it on has ES_AUTOHSCROLL - I know that not all of my fields in my app has this though.

If I compile my app with FW 10.06 it's fine, 11.09 fails - weird!!
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Copy/Paste

Post by Antonio Linares »

Peter,

We are working on unicode support for GETs and it seems as I may have emailed you a modified FiveHC.lib that has a change for unicode and thats where the problem is coming from.

Please check that in FWH\source\winapi\clpbrd.c you don't have this:

Code: Select all

HB_FUNC( GETCLPDATA ) // GETCLIPBOARDDATA( nFormat ) --> uData
{
   WORD wType = hb_parni( 1 );
   HGLOBAL hMem;

   // if( ( wType == CF_TEXT ) && ( EnumClipboardFormats( CF_TEXT ) != 0 ) )
   //    wType = CF_UNICODETEXT;
   
   ...
 
The bug seems to come from Windows EnumClipboardFormats() or maybe we are using it in a wrong way. I email you a modified FiveHC.lib

Thanks,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Copy/Paste

Post by Antonio Linares »

We are changing the previous code into this:

Code: Select all

   if( ( wType == CF_TEXT ) && ( EnumClipboardFormats( CF_TEXT ) == CF_UNICODETEXT ) )
      wType = CF_UNICODETEXT;
It seems to be working fine now :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Copy/Paste

Post by Antonio Linares »

Nope, we have to remove it for now. After copying an unicode text and then a normal text, it keeps reporting unicode...

// if( ( wType == CF_TEXT ) && ( EnumClipboardFormats( 0 ) == CF_UNICODETEXT ) )
// wType = CF_UNICODETEXT;
regards, saludos

Antonio Linares
www.fivetechsoft.com
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Copy/Paste

Post by StefanHaupt »

I found another bug. I modified the sample this way:

Code: Select all

    #include "FiveWin.ch"
    Function Main()

        Local oDlg,oGet1,oGet2,cVar1:="Test clipboard", cVar2:=space(30)
       
        DEFINE DIALOG oDlg TITLE "Testing Copy Paste"
       
            @01,01 GET oGet1 VAR cVar1 SIZE 100,12
            @03,01 GET oGet2 VAR cVar2 SIZE 100,12
       
        ACTIVATE DIALOG oDlg
         
    Return nil
First:
If you mark the text in the first get and try to insert another text from the clipboard, the old text should be replaced with the new one, but nothing happens. The old text is still there.

Second:
Write some text in the second get, mark this text and insert the text from the clipboard. The old text is not replaced, but the new one is appended to the old one.
kind regards
Stefan
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Copy/Paste

Post by Antonio Linares »

Stefan,

Class TGet was not properly processing WM_PASTE when some text was previously selected.

This is the fix for it:
Image

So this is the right code to use:

Code: Select all

      case nMsg == WM_PASTE
           if GetFocus() == ::hWnd
              CallWindowProc( ::nOldProc, ::hWnd, WM_PASTE, 0, 0 )
              ::oGet:Buffer = GetWindowText( ::hWnd )
              ::oGet:Pos = GetCaretPos()[ 2 ]
              ::oGet:Assign()
              if ::bChange != nil
                 Eval( ::bChange,,, Self )
              endif
           endif
           return 0
 
Thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Copy/Paste

Post by Antonio Linares »

It seems as this change is also required under some circunstances, anyhow I appreciate if you test it and provide your feedback, thanks :-)

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Copy/Paste

Post by StefanHaupt »

Antonio,

the sample is working fine now, thanks :D
kind regards
Stefan
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Copy/Paste

Post by PeterHarmes »

Any updates on this? The code change above didnt solve my problem i'm afraid

best regards,

Pete
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Copy/Paste

Post by Antonio Linares »

Pete,

The posted code seems to work fine, maybe you have not updated your lib properly.

We can send you the modified libs if you want to, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
PeterHarmes
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Copy/Paste

Post by PeterHarmes »

If you can send me the lib that would be great thanks

I'll let you know how I get on

regards,

Pete
Post Reply