Page 2 of 3

Re: Seleccionar todo el texto en un TextBox

Posted: Wed Sep 23, 2009 5:07 pm
by arroya2
Muchas gracias Maestro Roberto.

Rafael Pérez

Re: Seleccionar todo el texto en un TextBox

Posted: Wed Sep 23, 2009 5:34 pm
by arroya2
Hola Roberto.

Lamento tener que darte tanto la lata, pero es que he buscado las API de Windows y son muchísimas.

Me gustaría saber cuales son las que usa internamente HMG aparte de las tres que me has indicado.

Muy agradecido
Rafael Pérez

Re: Seleccionar todo el texto en un TextBox

Posted: Thu Sep 24, 2009 12:39 am
by Roberto Lopez
arroya2 wrote:Hola Roberto.

Lamento tener que darte tanto la lata, pero es que he buscado las API de Windows y son muchísimas.

Me gustaría saber cuales son las que usa internamente HMG aparte de las tres que me has indicado.

Muy agradecido
Rafael Pérez
HMG uses LOTS of WInAPi functions.

You should look at sources.

Regards,

Roberto.

Re: Seleccionar todo el texto en un TextBox

Posted: Thu Sep 24, 2009 7:18 am
by arroya2
Roberto Lopez wrote:
arroya2 wrote:Hola Roberto.

Lamento tener que darte tanto la lata, pero es que he buscado las API de Windows y son muchísimas.

Me gustaría saber cuales son las que usa internamente HMG aparte de las tres que me has indicado.

Muy agradecido
Rafael Pérez
HMG uses LOTS of WInAPi functions.

You should look at sources.

Regards,

Roberto.
Supongo que se refiere a las fuentes de HMG. ¿De dónde me las puedo bajar?

Muchas gracias y saludos.
Rafael Pérez

Re: Seleccionar todo el texto en un TextBox

Posted: Thu Sep 24, 2009 8:01 am
by Rathinagiri
You can see them from c:\hmg\source\*.c

Re: Seleccionar todo el texto en un TextBox

Posted: Thu Jan 28, 2010 9:42 am
by mol
gfilatov wrote: Hello Mol,

Take a look for the following sample:

Code: Select all

#include "minigui.ch"

Function Main

DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'Test' ;
MAIN ;
ON INIT OnInit( 'Text_2' , 'Form_1' )

@ 50,10 TEXTBOX Text_1 ;
VALUE 123 ;
FONT 'Verdana' SIZE 12 ;
TOOLTIP 'Numeric TextBox' ;
NUMERIC ;
MAXLENGTH 5

@ 100,10 TEXTBOX Text_2 ;
VALUE "123" ;
FONT 'Verdana' SIZE 12 ;
TOOLTIP 'Character TextBox'

@ 150,20 Button Button_1 ;
Caption "Disable" ;
Height 80 ;
Action DisableControls()


@ 150,120 Button Button_2 ;
Caption "Enable" ;
Height 80 ;
Action EnableControls()

END WINDOW
Form_1.Center
Form_1.Activate
Return Nil

Function DisableControls()
Form_1.Text_1.Enabled := .F.
Form_1.Text_2.Enabled := .F.

Return Nil

Function EnableControls()
Form_1.Text_1.Enabled := .T.
Form_1.Text_2.Enabled := .T.

Return Nil

#define EM_SETSEL 177
Function OnInit( cControlName , cParentForm )
Setfocus( GetControlHandle( cControlName , cParentForm ) )
SendMessage( GetControlHandle( cControlName , cParentForm ) , EM_SETSEL , 0 , -1 ) 

Return Nil
:idea:
I've returnd to this Idea, but, as I observed, this SendMessage causes selection only from mouse cursor to end of the field.
Could anybody test it?
Marek

Re: Seleccionar todo el texto en un TextBox

Posted: Wed Jan 19, 2022 11:16 am
by mol
I want to refresh this topic because this solution doesn't work with mouse.
Somebody has any idea how to select whole field after enter by mouse?

Re: Seleccionar todo el texto en un TextBox

Posted: Wed Jan 19, 2022 4:27 pm
by AUGE_OHR
hi Mol,

Code does work

Code: Select all

   hWndEdit := GetControlHandle( ControlName, ParentForm )
   SendMessage( hWndEdit, EM_SETSEL, nStartIndex, nEndIndex )
   // add this for Test
   DO EVENTS
   hb_idleSleep( 1.0 )
but "something" does delete my Color after "Sleep" when using Mouse ... hm

Re: Seleccionar todo el texto en un TextBox

Posted: Wed Jan 19, 2022 4:42 pm
by AUGE_OHR
hi,

try this with TEXTBOX

Code: Select all

ONGOTFOCUS MarkText( ThisWindow.Name, This.Name )
ONLOSTFOCUS DeHilite( ThisWindow.Name, This.Name )

Code: Select all

STATIC PROCEDURE MarkText( ParentForm, ControlName )
LOCAL cValue, hWndEdit, nStartIndex := 0, nEndIndex := - 1

   IF _IsControlDefined( ControlName, ParentForm )
      DoMethod( ParentForm, ControlName, "SetFocus" )
      SetProperty( ParentForm, ControlName, "CaretPos", nEndIndex )

      SetProperty( ParentForm, ControlName, "BackColor", SP_nColor11() )
      SetProperty( ParentForm, ControlName, "FontColor", SP_nColor12() )

      hWndEdit := GetControlHandle( ControlName, ParentForm )
      SendMessage( hWndEdit, EM_SETSEL, nStartIndex, nEndIndex )
   ENDIF
RETURN

Code: Select all

STATIC PROCEDURE DeHilite( ParentForm, ControlName )
   IF _IsControlDefined( ControlName, ParentForm )
      SetProperty( ParentForm, ControlName, "BackColor", SP_nColor5() )
      SetProperty( ParentForm, ControlName, "FontColor", SP_nColor6() )
   ENDIF
RETURN
it will "high-light" hole TEXTBOX but Cursor is at End of Entry

! Note : you must change Code to use "your" Color(s)

Re: Seleccionar todo el texto en un TextBox

Posted: Thu Jan 20, 2022 12:05 am
by Claudio Ricardo
Hola Rafael, En los textbox yo pongo el valor predeterminado en la propiedad ' Value ' al crear el control
o después con SetProperty ("Form_Name" , "Text_Name" , "Value" , "Valor predeterminado")
Cuando el usuario accede a ese textbox con la tecla Tab se resalta (highlight) y cualquier tecla alfanumérica
que presione borra el valor predeterminado por mi y lo reemplaza por lo que está escribiendo.
Por ejemplo: para editar un artículo cargo todos los textbox de la ventana de editar artículo con los
valores actuales y el usuario sólo cambia el que necesita, luego se leen todos los textbox y se actualiza
la base de datos.