FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Picture "@K" and selectall()
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Picture "@K" and selectall()
Posted: Mon Sep 26, 2011 09:31 PM
In order to emulate the "@K" feature in clipper I have been adding a bGotfocus codeblock to each get like below.
::oShipCons:bGotFocus := { || ::oShipCons:PostMsg( WM_KEYDOWN, VK_HOME ), ::oShipCons:selectall(), ::oShipCons:PostMsg( WM_KEYUP ) }

I think it would be better to have "@K" supported by the tget class. So I added 3 lines of code to tget.prg and it seems to work pretty good.
Can this be added to the regular class?

around line 1516 in tget.prg method gotfocus()
if ! Empty( ::cPicture ) .and. "K" $ ::cPicture
::SelectAll()
endif

here is the entire method
Code (fw): Select all Collapse
METHOD GotFocus( hCtlLost ) CLASS TGet

    ::lFocused = .t.

    #ifdef __XHARBOUR__
       ::oGet:VarGet()
    #endif

    #ifdef __XPP__
       DEFAULT ::lClrFocus := .F.
    #endif

    if ! Empty( ::cPicture ) .and. ::oGet:Type == "N"
       ::oGet:Picture := StrTran( ::cPicture, ",", "" )
    endif

    if ! ::lDrag
       ::oGet:KillFocus()   // to properly initialize internal status
       ::oGet:SetFocus()
       if Upper( ::oWnd:ClassName() ) == "TCOMBOBOX"
          ::oGet:Buffer := ::oGet:Original
       endif
       if ::lClrFocus
          ::nOldClrPane = ::nClrPane
          ::SetColor( ::nClrText,;
              If( ValType( ::nClrFocus ) == "B", Eval( ::nClrFocus ), ::nClrFocus ) )
       endif
       ::DispText()
       if ::oGet:Type $ "DN" .or. ::oGet:Pos != 1 // 28/06/05 AL
          ::nPos := ::oGet:Pos // 1   28/06/05 AL
       endif
       ::oGet:Pos := ::nPos
       ::SetPos( ::nPos )
       CallWindowProc( ::nOldProc, ::hWnd, WM_SETFOCUS )
       if Set( _SET_INSERT )
          DestroyCaret()
          CreateCaret( ::hWnd, 0, 6, ::nGetChrHeight() - 1 )
          ShowCaret( ::hWnd )
       endif
       // Here is the "@K" modification
       if ! Empty( ::cPicture ) .and. "K" $ ::cPicture
         ::SelectAll()
       endif
    else
       HideCaret( ::hWnd )
    endif

    Super:GotFocus( hCtlLost )

return 0
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Picture "@K" and selectall()
Posted: Tue Sep 27, 2011 02:17 PM
I had to modify this some. I moved the code after the Super:GotFocus( hCtlLost ) and added a check if the control was readonly
This is around line 1521 in tget.prg
Code (fw): Select all Collapse
    Super:GotFocus( hCtlLost )
       // GDF Modified 09/27/2011
       if ! Empty( ::cPicture ) .and. "K" $ ::cPicture .and. ! ::lReadOnly
         ::SelectAll()
       endif
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Picture "@K" and selectall()
Posted: Tue Sep 27, 2011 11:42 PM
Gale,

Back in 2006 I did a similar modification for @K. I changed the GoHome() method in TGet. Below is my change. You might want to try it and compare to yours.

I note that in FWH 10.08 still has the same original GoHome() method as the one I modified in 2006.

Regards,
James


Code (fw): Select all Collapse
method GoHome() class TGet

   ::oGet:Home()
   //if ::Type == "N"  // flag to clear buffer if typing is detected
   if ::oGet:Type == "N" .or. "K" $ upper(::oGet:Picture)   // J Bott
      ::oGet:Clear := .t.
   endif
   ::SetPos(::oGet:Pos)

return Self
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: Picture "@K" and selectall()
Posted: Wed Sep 28, 2011 04:55 AM

I did not notice the picture "@K" working. The modification you did will allow the contents of the get to be erased with the next key pressed?
The users seem to like the selectall() visual indication that the contents will be erased when a key is pressed.

Continue the discussion