- Code: Select all Expand view
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oDlg
LOCAL oGet
LOCAL cVar := "This is a test"
DEFINE DIALOG oDlg
@ 1, 1 GET oGet VAR cVar MEMO SIZE 100, 30
@ 3, 1 BUTTON "&Close" ACTION oDlg:End()
oDlg:bStart = { || oGet:SetSel( 2, 4 ) }
// oDlg:bStart = { || oGet:SetPos( 2, 4 ) }
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
You will see that SetSel() selects "is" while SetPos() selects "hi". A possible fix is to change the SetPos() method this way:
- Code: Select all Expand view
METHOD SetPos( nStart, nEnd ) INLINE ;
nEnd := If( nEnd == nil, nStart, nEnd ),;
::SendMsg( EM_SETSEL, nStart - If( nStart > 0, 0, 0 ), nEnd - If( nEnd > 0, 0, 0 ) ),;
::nPos := nStart
or, of course, completely remove the If().
EMG