Page 2 of 2

PostPosted: Thu Aug 10, 2006 8:36 pm
by Antonio Linares
James,

> The Cut routine also needs a similar fix. This seems to be working:

Thanks,

> Now Ctrl-X and Ctrl-V need fixing

In Method KeyDown() please remove these 3 lines:
Code: Select all  Expand view
      case ( nKey == VK_INSERT .and. GetKeyState( VK_SHIFT ) ) .or. ;
           ( nKey == ASC("V") .and. GetKeyState( VK_CONTROL ) ) .or. ;
           ( nKey == ASC('X') .and. GetKeyState( VK_CONTROL ) ) .and. ;
           ! lAnd( nFlags, 2 ** 29 )

          if ! ::lReadOnly
             CallWindowProc( ::nOldProc, ::hWnd, WM_KEYDOWN, nKey, nFlags )
             SysRefresh()
             if ValType( ::oGet:buffer ) = "C"
                ::oGet:buffer = Pad( GetWindowText( ::hWnd ), Len( ::oGet:buffer ) )
                SetWindowText( ::hWnd, ::oGet:buffer )
             else
                ::oGet:buffer = GetWindowText( ::hWnd )
             endif
             ::oGet:Assign()
             // ::GetSelPos( @nLo, @nHi )      THIS
             // ::nPos = nHi + 1                    THIS
             // ::oGet:Pos = ::nPos               THIS
             if ::bChange != nil
                Eval( ::bChange, nKey, nFlags, Self )
             endif
          endif

          return 0


Now it seems to work fine. We appreciate your feedback, thanks

PostPosted: Thu Aug 10, 2006 9:44 pm
by James Bott
Antonio,

I had to make some additions to get it working. There are two new sections of code. Also I had to add a new LOCAL oClp at the top of the method.

James

Code: Select all  Expand view
     case ( nKey == VK_INSERT .and. GetKeyState( VK_SHIFT ) ) .or. ;
           ( nKey == ASC("V") .and. GetKeyState( VK_CONTROL ) ) .or. ;
           ( nKey == ASC('X') .and. GetKeyState( VK_CONTROL ) )

          if ! ::lReadOnly

           // new section
           DEFINE CLIPBOARD oClp OF Self FORMAT TEXT
           nPos := Len( oClp:GetText() )
           oClp:End()
           // end of new section

             CallWindowProc( ::nOldProc, ::hWnd, WM_KEYDOWN, nKey, nFlags )
             SysRefresh()
             if ValType( ::oGet:buffer ) = "C"
                ::oGet:buffer = Pad( GetWindowText( ::hWnd ), Len( ::oGet:buffer ) )
                SetWindowText( ::hWnd, ::oGet:buffer )
             else
                ::oGet:buffer = GetWindowText( ::hWnd )
             endif
             ::oGet:Assign()
             //::GetSelPos( @nLo, @nHi )
             //::nPos = nHi + 1
             //::oGet:Pos = ::nPos

             // New section
             do case
                case nKey == ASC('X')
                   ::setPos( nPos )
                case nKey == ASC('V')
                   ::setPos( ::oGet:pos )
             endcase
             // end of new section

             if ::bChange != nil
                Eval( ::bChange, nKey, nFlags, Self )
             endif
          endif

          return 0

PostPosted: Thu Aug 10, 2006 10:36 pm
by Roger Seiler
Antonio & James,

Antonio's fix with James' modification to WM_CUT works like a charm!

However, anyone inserting this code into their version of TGet.prg will need to insert the following defines at the top of the file:

#define WM_CUT 768 // 0x300
#define WM_PASTE 770 // 0x302

Also, be sure to declare the HandleEvent() method in the list of the TGet class's methods up near the top of the prg where the class is defined....
...
METHOD HandleEvent()
...

Whoops - I see that James has been doing more work while I was typing this in. I'll have to try out his added mods now.

- Roger

PostPosted: Thu Aug 10, 2006 10:42 pm
by James Bott
Roger,

Thanks for pointing out those missing items.

James

PostPosted: Fri Aug 11, 2006 5:56 pm
by Randal
Antonio, James, Roger,

Thanks a lot for fixing this!

Best Regards,
Randal Ferguson