Seleccionar todo el texto en un TextBox
Moderator: Rathinagiri
Seleccionar todo el texto en un TextBox
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
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
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Seleccionar todo el texto en un TextBox
The following code let you select text in a TextBox.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
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 )
Roberto.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Seleccionar todo el texto en un TextBox
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.
Can anybody imagine to call a C API function in a single line?
I wonder it is possible from HMG alone.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Seleccionar todo el texto en un TextBox
Gracias Roberto.Roberto Lopez wrote:The following code let you select text in a TextBox.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
You need to provide:
cControlName
cParentForm
nFirstCharacter
nLastCharacter
Additionaly you must define the following constant:
#define EM_SETSEL 177
Regards,Code: Select all
SendMessage( GetControlHandle(cControlName , cParentForm ) , EM_SETSEL , nFirstCharacter , nLastCharacter )
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
I'm wondering, how to select whole numeric textbox when I enter in this field by mouse?Roberto Lopez wrote:
Additionaly you must define the following constant:
#define EM_SETSEL 177
Regards,Code: Select all
SendMessage( GetControlHandle(cControlName , cParentForm ) , EM_SETSEL , nFirstCharacter , nLastCharacter )
Roberto.
I've tried to put this code in OnGotFocus exception, but it doesn't work
Re: Seleccionar todo el texto en un TextBox
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
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
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.
I don't know, how to select all characters in any field during initialisation of window.
Re: Seleccionar todo el texto en un TextBox
Hello Mol,mol wrote:...
I don't know, how to select all characters in any field during initialisation of window.
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
Kind Regards,
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Grigory Filatov
"Everything should be made as simple as possible, but no simpler." Albert Einstein
Re: Seleccionar todo el texto en un TextBox
Hola Grigory.
Me podrías indicar donde están documentadas las funciones:
- Setfocus()
- GetControlHandle()
- SendMessage()
Gracias y Saludos
Rafael Pérez
Me podrías indicar donde están documentadas las funciones:
- Setfocus()
- GetControlHandle()
- SendMessage()
Gracias y Saludos
Rafael Pérez
- Roberto Lopez
- HMG Founder
- Posts: 4004
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Seleccionar todo el texto en un TextBox
These are Windows API functions used internally by HMG.arroya2 wrote:Hola Grigory.
Me podrías indicar donde están documentadas las funciones:
- Setfocus()
- GetControlHandle()
- SendMessage()
Gracias y Saludos
Rafael Pérez
You can found information about that in MSDN.
Regards,
Roberto.
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)