Page 1 of 3
Seleccionar todo el texto en un TextBox
Posted: Mon Sep 07, 2009 11:07 am
by arroya2
Español:
Hola.
Lo que necesito básicamente es que el usuario, en algunos formularios, tenga valores predeterminados, pero si estos no son los que necesita, simplemente con teclear el nuevo valor, se borra el valor predeterminado.
Gracias
English:
Hello.
What I need is basically a user, in some forms, have defaults, but if these are not needed, simply by typing the new value, clears the default.
Thanks
Re: Seleccionar todo el texto en un TextBox
Posted: Sun Sep 13, 2009 2:26 pm
by Roberto Lopez
arroya2 wrote:Español:
Hola.
Lo que necesito básicamente es que el usuario, en algunos formularios, tenga valores predeterminados, pero si estos no son los que necesita, simplemente con teclear el nuevo valor, se borra el valor predeterminado.
Gracias
English:
Hello.
What I need is basically a user, in some forms, have defaults, but if these are not needed, simply by typing the new value, clears the default.
Thanks
The following code let you select text in a TextBox.
You need to provide:
cControlName
cParentForm
nFirstCharacter
nLastCharacter
Additionaly you must define the following constant:
#define EM_SETSEL 177
Code: Select all
SendMessage( GetControlHandle(cControlName , cParentForm ) , EM_SETSEL , nFirstCharacter , nLastCharacter )
Regards,
Roberto.
Re: Seleccionar todo el texto en un TextBox
Posted: Sun Sep 13, 2009 5:11 pm
by Rathinagiri
Thanks a lot Roberto.
Can anybody imagine to call a C API function in a single line?
I wonder it is possible from HMG alone.

Re: Seleccionar todo el texto en un TextBox
Posted: Fri Sep 18, 2009 7:15 am
by arroya2
Roberto Lopez wrote:arroya2 wrote:Español:
Hola.
Lo que necesito básicamente es que el usuario, en algunos formularios, tenga valores predeterminados, pero si estos no son los que necesita, simplemente con teclear el nuevo valor, se borra el valor predeterminado.
Gracias
English:
Hello.
What I need is basically a user, in some forms, have defaults, but if these are not needed, simply by typing the new value, clears the default.
Thanks
The following code let you select text in a TextBox.
You need to provide:
cControlName
cParentForm
nFirstCharacter
nLastCharacter
Additionaly you must define the following constant:
#define EM_SETSEL 177
Code: Select all
SendMessage( GetControlHandle(cControlName , cParentForm ) , EM_SETSEL , nFirstCharacter , nLastCharacter )
Regards,
Roberto.
Gracias Roberto.
Lo que me indica no me suena nada. Le indico que soy principiante. Si me puede indicar donde puedo encontrar un ejemplo que ilustre su información o si me puede ilustrar con un ejemplo, se lo agradeceré.
Muchas gracias. Rafael Pérez
Re: Seleccionar todo el texto en un TextBox
Posted: Tue Sep 22, 2009 5:59 am
by mol
Roberto Lopez wrote:
Additionaly you must define the following constant:
#define EM_SETSEL 177
Code: Select all
SendMessage( GetControlHandle(cControlName , cParentForm ) , EM_SETSEL , nFirstCharacter , nLastCharacter )
Regards,
Roberto.
I'm wondering, how to select whole numeric textbox when I enter in this field by mouse?
I've tried to put this code in OnGotFocus exception, but it doesn't work

Re: Seleccionar todo el texto en un TextBox
Posted: Tue Sep 22, 2009 9:34 am
by arroya2
Hola.
He observado que en el modo edición, cuando se cambia de un campo a otro con la tecla TAB, en el campo siguiente queda seleccionado todo el contenido.
Pero cuando se edita, en el primer campo de la edición no se selecciona nada del contenido de ese campo. ¿Porqué? ¿Cómo se puede resolver esto para que el contenido de ese primer campo también quede seleccionado?
Saludos
Re: Seleccionar todo el texto en un TextBox
Posted: Tue Sep 22, 2009 10:16 am
by mol
I wanna get effect of selection of whole field - getting focus of him by a mouse. Of course it works if I'm navigating with TAB.
I don't know, how to select all characters in any field during initialisation of window.
Re: Seleccionar todo el texto en un TextBox
Posted: Tue Sep 22, 2009 10:37 am
by gfilatov
mol wrote:...
I don't know, how to select all characters in any field during initialisation of window.
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

Re: Seleccionar todo el texto en un TextBox
Posted: Wed Sep 23, 2009 1:05 pm
by arroya2
Hola Grigory.
Me podrías indicar donde están documentadas las funciones:
- Setfocus()
- GetControlHandle()
- SendMessage()
Gracias y Saludos
Rafael Pérez
Re: Seleccionar todo el texto en un TextBox
Posted: Wed Sep 23, 2009 1:40 pm
by Roberto Lopez
arroya2 wrote:Hola Grigory.
Me podrías indicar donde están documentadas las funciones:
- Setfocus()
- GetControlHandle()
- SendMessage()
Gracias y Saludos
Rafael Pérez
These are Windows API functions used internally by HMG.
You can found information about that in MSDN.
Regards,
Roberto.