TMultiGet:SetSel() and TMultiGet:SetPos() methods

TMultiGet:SetSel() and TMultiGet:SetPos() methods

Postby Enrico Maria Giordano » Mon Feb 06, 2006 9:59 am

There is a difference in the selected range between the two methods. Look at this sample:

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
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 58 guests