TextBox Display and GotFocus
Moderator: Rathinagiri
-
- Posts: 273
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
TextBox Display and GotFocus
Hi All,
Default Behavior: When a TextBox control first gets focus the text inside initially appears formatted as "white letters on a dark blue background". In my GotFocus, however, I programmatically change that control's BackColor (from white). This is to show current focus to the user.
My Problem: I have not figured out how to programmatically remove that default "white letters on a dark blue background" formatting. I have attempted various things including setting the control's CaretPos to 0. All have failed to remove this "white letters on a dark blue background" formatting without manually clicking inside the control. See bottom example (red arrow).
I am sure that this is not complicated to more experienced HMG/Harbour users. I would really appreciate any assistance here.
Thank you, Red2
Default Behavior: When a TextBox control first gets focus the text inside initially appears formatted as "white letters on a dark blue background". In my GotFocus, however, I programmatically change that control's BackColor (from white). This is to show current focus to the user.
My Problem: I have not figured out how to programmatically remove that default "white letters on a dark blue background" formatting. I have attempted various things including setting the control's CaretPos to 0. All have failed to remove this "white letters on a dark blue background" formatting without manually clicking inside the control. See bottom example (red arrow).
I am sure that this is not complicated to more experienced HMG/Harbour users. I would really appreciate any assistance here.
Thank you, Red2
- SALINETAS24
- Posts: 667
- Joined: Tue Feb 27, 2018 3:06 am
- DBs Used: DBF
- Contact:
Re: TextBox Display and GotFocus
Hola, creo que ese color es el predefinido de Windows y lo que hace es marcar el campo.
Si quieres evitarlo puedes probar a enviar en el ON GOTFOCUS (_PushKey(VK_END)), para mandar el cursor al final del campo, o al Inicio (la combinación que quieras).
Espero que que te sirva, saludos virtuales !!
Si quieres evitarlo puedes probar a enviar en el ON GOTFOCUS (_PushKey(VK_END)), para mandar el cursor al final del campo, o al Inicio (la combinación que quieras).
Espero que que te sirva, saludos virtuales !!
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no.
-
- Posts: 273
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: TextBox Display and GotFocus
Hi Salinetas24,
Thank you for your suggestion. I am not familiar with the function _PushKey() and have not been able to find any documentation. Can you point me to where it is documented? I assume that "VK_END" refers to a defined value. Unfortunately I do not know that either.
Thanks again for all of your kind help!
Regards, Red2
Thank you for your suggestion. I am not familiar with the function _PushKey() and have not been able to find any documentation. Can you point me to where it is documented? I assume that "VK_END" refers to a defined value. Unfortunately I do not know that either.
Thanks again for all of your kind help!
Regards, Red2
- Claudio Ricardo
- Posts: 367
- Joined: Tue Oct 27, 2020 3:38 am
- DBs Used: DBF, MySQL, MariaDB
- Location: Bs. As. - Argentina
Re: TextBox Display and GotFocus
Hola... _PushKey () o HMG_PressKey () si no me equivoco ponen en el buffer de teclado el valor de una tecla,
en el caso del ejemplo: la tecla "End" con "VK_END" pero puede ser cualquier otra...
Salinetas propone que al tomar foco el control sea como si hubieras pulsado la tecla "End"
lo que haría desplazarte al final de la lista.
En la ayuda del IDE HMG, Advanced, Read Keyboard and Mouse hay más funciones así.
en el caso del ejemplo: la tecla "End" con "VK_END" pero puede ser cualquier otra...
Salinetas propone que al tomar foco el control sea como si hubieras pulsado la tecla "End"
lo que haría desplazarte al final de la lista.
En la ayuda del IDE HMG, Advanced, Read Keyboard and Mouse hay más funciones así.
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
WhatsApp / Telegram: +54 911-63016162
- Claudio Ricardo
- Posts: 367
- Joined: Tue Oct 27, 2020 3:38 am
- DBs Used: DBF, MySQL, MariaDB
- Location: Bs. As. - Argentina
Re: TextBox Display and GotFocus
Hace un par de dias subi algo que te puede servir para cambiar los colores de TextBox:
download/file.php?id=10593
Fijate que primero seteo un color en el control y luego al tomar foco lo cambia con la funcion.
En el control Spinner hay un parpadeo pero en los demás controles funciona bién.
download/file.php?id=10593
Fijate que primero seteo un color en el control y luego al tomar foco lo cambia con la funcion.
En el control Spinner hay un parpadeo pero en los demás controles funciona bién.
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
WhatsApp / Telegram: +54 911-63016162
-
- Posts: 273
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: TextBox Display and GotFocus
Gracias Salinetas24 y Claudio,
Agradezco tu amable ayuda. Usaré tu información el lunes. ¡Que tengas un gran fin de semana y gracias de nuevo!
Agradezco tu amable ayuda. Usaré tu información el lunes. ¡Que tengas un gran fin de semana y gracias de nuevo!
-
- Posts: 273
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: TextBox Display and GotFocus
Hi Salinetas24 and Claudio,
Thanks to your kind help my intended behavior is now working.
I never found any documentation for PushKey(). However, in the IDE help you pointed me to I found HMG_PressKey ( nVK1, nVK2, ... ). That worked fine in a TextBox control.
I initially had a problem with the EditBox control. For it I needed to HMG_PressKey( VK_UP, VK_UP, VK_UP ) to proceed the HMG_PressKey( VK_HOME) otherwise the cursor would not move to the actual beginning.
Thanks again!
Thanks to your kind help my intended behavior is now working.
I never found any documentation for PushKey(). However, in the IDE help you pointed me to I found HMG_PressKey ( nVK1, nVK2, ... ). That worked fine in a TextBox control.
I initially had a problem with the EditBox control. For it I needed to HMG_PressKey( VK_UP, VK_UP, VK_UP ) to proceed the HMG_PressKey( VK_HOME) otherwise the cursor would not move to the actual beginning.
Thanks again!
- SALINETAS24
- Posts: 667
- Joined: Tue Feb 27, 2018 3:06 am
- DBs Used: DBF
- Contact:
Re: TextBox Display and GotFocus
Lo importante es que lo hayas resuelto.Red2 wrote: ↑Mon Apr 12, 2021 6:34 pm Hi Salinetas24 and Claudio,
Thanks to your kind help my intended behavior is now working.
I never found any documentation for PushKey(). However, in the IDE help you pointed me to I found HMG_PressKey ( nVK1, nVK2, ... ). That worked fine in a TextBox control.
I initially had a problem with the EditBox control. For it I needed to HMG_PressKey( VK_UP, VK_UP, VK_UP ) to proceed the HMG_PressKey( VK_HOME) otherwise the cursor would not move to the actual beginning.
Thanks again!
En cuanto a la función _PushKey(), esta incluida en h_hotkey.prg, junto a HMG_PressKey. Son similares, la 1 solo envía una pulsación de una tecla, y la segunda puede enviar una secuencia de pulsaciones.
Un saludo.
Como dijo el gran pensador Hommer Simpson..., - En este mundo solo hay 3 tipos de personas, los que saben contar y los que no.
- Claudio Ricardo
- Posts: 367
- Joined: Tue Oct 27, 2020 3:38 am
- DBs Used: DBF, MySQL, MariaDB
- Location: Bs. As. - Argentina
Re: TextBox Display and GotFocus
Hi... Maybe it help you:
Here another Harbour function for put key value in kb buffer:
https://harbour.github.io/doc/hbnf.html#ft_putkey
Cursor position in Grid and EditBox:
http://www.pctoledo.com.br/forum/viewto ... 45&t=17935
http://mail.hmgforum.com/viewtopic.php?f=5&t=5319
Here another Harbour function for put key value in kb buffer:
https://harbour.github.io/doc/hbnf.html#ft_putkey
Cursor position in Grid and EditBox:
http://www.pctoledo.com.br/forum/viewto ... 45&t=17935
http://mail.hmgforum.com/viewtopic.php?f=5&t=5319
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
WhatsApp / Telegram: +54 911-63016162
- AUGE_OHR
- Posts: 2062
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: TextBox Display and GotFocus
hi,
it does work when use Pushkey() ... but
---
have a look into c:\hmg.3.4.4\SOURCE\h_textbox.prg
you will find
https://docs.microsoft.com/en-us/window ... /em-setsel
it does "set mark", which is default under Windows OS, what you do not want when Control get Focus ...
---
when nStartIndex = nEndIndex = 0 than Cursor is set to left before 1st Sign
it does work when use Pushkey() ... but
---
have a look into c:\hmg.3.4.4\SOURCE\h_textbox.prg
you will find
Code: Select all
SendMessage( _HMG_SYSDATA[ 3 ] [ i ], EM_SETSEL ...
it does "set mark", which is default under Windows OS, what you do not want when Control get Focus ...
---
Code: Select all
ON GOTFOCUS API_selectRange( ThisWindow.Name, This.Name)
Code: Select all
#include "DLL.CH"
#xtranslate DllCall => HMG_CallDLL
PROCEDURE API_selectRange(cForm, cControl, nStartIndex, nEndIndex)
LOCAL hEdit := GetControlHandle( cControl, cForm )
DEFAULT nStartIndex TO 0
DEFAULT nEndIndex TO 0
DLLCALL("user32.dll",,"SendMessage", hEdit, EM_SETSEL, nStartIndex, nEndIndex)
RETURN
have fun
Jimmy
Jimmy