Page 1 of 1

"mark" Text in EDITBOX

Posted: Mon Dec 21, 2020 2:18 am
by AUGE_OHR
hi,

i want to "mark" Text in a EDITBOX so i need 2 Position
using "CaretPos" i got 1st Position and add LEN(Text) is 2nd Position.

so how to

Code: Select all

setMarked( { nFrom, nTo } )

Re: "mark" Text in EDITBOX

Posted: Mon Dec 21, 2020 2:34 am
by danielmaximiliano
Quisas : https://docs.microsoft.com/en-us/window ... /em-setsel
Winuser.h

example : C:\Harbour\contrib\gtwvw

Re: "mark" Text in EDITBOX

Posted: Mon Dec 21, 2020 2:35 pm
by srvet_claudio
Hi, see:


HB_FUNC ( SETSEL )
{
HWND hWnd = HMG_parnl (1);
INT nStart = hb_parnl (2);
INT nEnd = hb_parnl (3);
SendMessage( hWnd, EM_SETSEL, nStart, nEnd );
}

Re: "mark" Text in EDITBOX

Posted: Mon Dec 21, 2020 9:33 pm
by AUGE_OHR
hi,

now i can "mark" wrong Word in EDITBOX :D
but i have Problem to "replace" wrong Word which is marked :(

Code: Select all

   // set focus
   DoMethod( "Form_1", "Editbox_1", "SETFOCUS" )
   // remove marked text and insert the replacement
   API_SelectRange( nFrom - 1, nTo - 1 )         // ZERO-based

   // why does this not work ???
   API_ReplaceSelection(@cReplace)
i have check nFrom, nTo and all is OK but it only "cut-out" wrong Word and do not "replace" :o

so what i´m doing wrong :idea:

Code: Select all

PROCEDURE API_SelectRange( nStartIndex, nEndIndex )
LOCAL hEdit := GetProperty( "Form_1", "Editbox_1", "Handle" )
   DoMethod( "Form_1", "Editbox_1", "SETFOCUS" )
   SendMessage( hEdit, EM_SETSEL, nStartIndex, nEndIndex )
RETURN

Code: Select all

PROCEDURE API_GetSelection( nStart, nEnd )
LOCAL hEdit := GetProperty( "Form_1", "Editbox_1", "Handle" )
   DoMethod( "Form_1", "Editbox_1", "SETFOCUS" )
   SendMessage( hEdit, EM_GETSEL, @nStart, @nEnd )
RETURN

Code: Select all

PROCEDURE API_ReplaceSelection( cText )
LOCAL hEdit := GetProperty( "Form_1", "Editbox_1", "Handle" )
   DoMethod( "Form_1", "Editbox_1", "SETFOCUS" )
   SendMessage( hEdit, EM_REPLACESEL, TRUE, cText )
RETURN

Re: "mark" Text in EDITBOX

Posted: Wed Dec 23, 2020 8:25 pm
by AUGE_OHR
hi,

found a Workaround

Code: Select all

   // remove marked text and insert the replacement
   // why does this not work ???
   //   ::ReplaceSelection(@cReplace)

   // Workaround : use Clipboard
   System.EmptyClipboard
   System.Clipboard := cReplace
   ::API_Paste()
   System.EmptyClipboard