CaretPos en EDITBOX

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

CaretPos en EDITBOX

Post by andyglezl »

Hola

En un EditBox, estoy utilizando lo siguiente para mover de ubicación el cursor,
lo hace ok, pero no me actualiza el EditBox físicamente. Algo que me falte ?
---------------------------------------------------------------------------
Hello

In an EditBox, I am using the following to move the cursor location,
it does ok, but I do not update the EditBox physically. Something missing me?
---------------------------------------------------------------------------

Code: Select all

ACTION ( w_test.EB_1.CaretPos := 1, w_test.EB_1.SetFocus )  TOOLTIP "Inicio"

ACTION ( w_test.EB_1.CaretPos := LEN( w_test.EB_1.Value ), w_test.EB_1.SetFocus )  TOOLTIP "Fin"
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: CaretPos en EDITBOX

Post by andyglezl »

Presentandolo de otra forma, como simular que moví la ScrollBar hacia el
"Inicio" ó el "Fin" con programacion en el EditBox ?
-----------------------------------------------------------------------
Presenting it in another way, as I moved simulate the ScrollBar to the
"Start" or the "End" with programming in EditBox?
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: CaretPos en EDITBOX

Post by andyglezl »

Ya mejor me voy a dormir...
Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: CaretPos en EDITBOX

Post by srvet_claudio »

Andrés aquí te dejo un ejemplo que funciona perfecto en HMG.3.2

Code: Select all


#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'HMG Demo' ;
		MAIN 


		@ 30,10 EDITBOX Edit_1 ;
			WIDTH 410 ;
			HEIGHT 140 ;
			VALUE 'EditBox!!' ;
			TOOLTIP 'EditBox' ;
			MAXLENGTH 255 ;
         nohscroll;

		DEFINE BUTTON B
			ROW	250
			COL	10
			WIDTH	130
			CAPTION 'Set CaretPos 0'
			ACTION	( Form_1.Edit_1.CaretPos := 0 , Form_1.Edit_1.SetFocus )
		END BUTTON

		DEFINE BUTTON C
			ROW	250
			COL	150
			WIDTH	130
			CAPTION	'Set CaretPos End'
			ACTION	( Form_1.Edit_1.CaretPos := HMG_LEN(Form_1.Edit_1.Value) , Form_1.Edit_1.SetFocus )
		END BUTTON


	END WINDOW

	Form_1.Center()

	Form_1.Activate()

Return Nil

Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: CaretPos en EDITBOX

Post by andyglezl »

Gracias Dr. Claudio

De hecho si me funciona igual como su ejemplo, aquí mas bien necesito
que al momento de oprimir el boton "Set CaretPos End", el Editbox me
muestre el final del texto desplegado.
Así mismo, cuando presione "Set CaretPos 0", me muestre el principio del texto.
Attachments
caretpos2.jpg
caretpos2.jpg (20.22 KiB) Viewed 2760 times
caretpos.jpg
caretpos.jpg (20.53 KiB) Viewed 2760 times
Andrés González López
Desde Guadalajara, Jalisco. México.
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: CaretPos en EDITBOX

Post by Javier Tovar »

Hola Dr. Claudio,

Gracias por compartir :D

Saludos
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: CaretPos en EDITBOX

Post by srvet_claudio »

andyglezl wrote:Gracias Dr. Claudio

De hecho si me funciona igual como su ejemplo, aquí mas bien necesito
que al momento de oprimir el boton "Set CaretPos End", el Editbox me
muestre el final del texto desplegado.
Así mismo, cuando presione "Set CaretPos 0", me muestre el principio del texto.
Esto simula CRTL+HOME y CRTL+END

Code: Select all


#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'HMG Demo' ;
		MAIN 


		@ 30,10 EDITBOX Edit_1 ;
			WIDTH 410 ;
			HEIGHT 140 ;
			VALUE 'EditBox!!' ;
			TOOLTIP 'EditBox' ;
			MAXLENGTH 255 ;
         nohscroll;

#define VK_CONTROL	17
#define VK_END	35
#define VK_HOME	36

         
		DEFINE BUTTON B
			ROW	250
			COL	10
			WIDTH	130
			CAPTION 'Set CaretPos 0'
			ACTION	( Form_1.Edit_1.CaretPos := 0, PressCTRLplus (VK_HOME), Form_1.Edit_1.SetFocus )
		END BUTTON

		DEFINE BUTTON C
			ROW	250
			COL	150
			WIDTH	130
			CAPTION	'Set CaretPos End'
			ACTION	( Form_1.Edit_1.CaretPos := HMG_LEN(Form_1.Edit_1.Value), PressCTRLplus (VK_END), Form_1.Edit_1.SetFocus )
		END BUTTON


	END WINDOW

	Form_1.Center()

	Form_1.Activate()

Return Nil



FUNCTION PressCTRLplus (nVK)
   Keybd_Event ( VK_CONTROL ,.F.)
   Keybd_Event ( nVK        ,.F.)
   Keybd_Event ( nVK        ,.T.)
   Keybd_Event ( VK_CONTROL ,.T.)
RETURN

Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: CaretPos en EDITBOX

Post by andyglezl »

Perfecto Dr. Soto !

Funciona tal cual, muchas gracias por su ayuda.
Andrés González López
Desde Guadalajara, Jalisco. México.
Post Reply