"mark" Text in EDITBOX

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

"mark" Text in EDITBOX

Post 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 } )
have fun
Jimmy
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: "mark" Text in EDITBOX

Post by danielmaximiliano »

Quisas : https://docs.microsoft.com/en-us/window ... /em-setsel
Winuser.h

example : C:\Harbour\contrib\gtwvw
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
srvet_claudio
Posts: 2220
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: "mark" Text in EDITBOX

Post 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 );
}
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: "mark" Text in EDITBOX

Post 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
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: "mark" Text in EDITBOX

Post 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
have fun
Jimmy
Post Reply