EDITBOX

HMG en Español

Moderator: Rathinagiri

Post Reply
jorge.posadas
Posts: 190
Joined: Mon May 19, 2014 7:43 pm
DBs Used: DBF, SQLite, MS-SQL, ACCESS, MariaDB (en proceso)
Location: Morelia, Mich. México
Contact:

EDITBOX

Post by jorge.posadas »

Grupo MHG

Tengo un control EDITBOX, donde el usuario capturará las caracteristicas del artículo, pero necesito que cuando llegue a 80 caracteres, AUTOMATICAMENTE pase a la segunda línea, esto con la finalidad de que lo que vaya escribiendo no sobre pase el ancho visual del EDITBOX

y si fuera posible que muestre el número de caracteres que va escribiendo y cuando llegue a limite de 80 de un salto de línea y que se reincie el contador de caracteres.

Espero me haya dado a entender con mi necesidad y de antemano agradezco la ayuda.
Cordialmente

POSADAS SOFTWARE
Jorge Posadas Ch.
Programador independiente
Morelia, Mich.
M é x i c o .
Movil +52 44 3734 1858
SKYPE: jorge.posadasch
Email: jorge.posadas@posoft.mx
User avatar
serge_girard
Posts: 3336
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: EDITBOX

Post by serge_girard »

Jorge,

maybe this can help you to get starting...:

Code: Select all

#include "hmg.ch"
FUNCTION MAIN()
/*****************/
DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 930 HEIGHT 400 ;
   TITLE ' T e s t';
   FONT "Arial" SIZE 09

   ON KEY ESCAPE ACTION Form_1.Release  

   @ 10,840 LABEL LABEL_LEN_TB_1 ;
      VALUE " " ;
      WIDTH 100 ;
      HEIGHT 35 ;
      BOLD

   DEFINE EDITBOX TB_1
      ROW	 10
      COL	 10
      WIDTH  820 
      HEIGHT 250 
      VALUE '1234567890123456789012345678901234567890123456789012345678901234567890'  
      TOOLTIP '' 
      MAXLENGTH 2000	 
      ON CHANGE TEST_LEN() 
   END EDITBOX
    
END WINDOW
 
Form_1.TB_1.SetFocus

CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
 
RETURN


FUNCTION TEST_LEN()
/******************/
LOCAL cResult  := "", n, nPOS

Form_1.LABEL_LEN_TB_1.Value := LEN(Form_1.TB_1.Value)

FOR n := 80 TO 800 STEP 80 
   IF LEN(Form_1.TB_1.Value) == 80
      FOR nPos := 1 TO Len( Form_1.TB_1.Value ) STEP 80
         cResult += SubStr( Form_1.TB_1.Value, nPos, 80 ) + CRLF
      NEXT
      Form_1.TB_1.Value := cResult
      EXIT
   ENDIF
NEXT
N.B.
1 - Every CRLF will add 2 to the LEN
2 - Caret position is be moved to the end of the line... I cannot find the function to do this. I will look further.
There's nothing you can do that can't be done...
User avatar
AUGE_OHR
Posts: 2096
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: EDITBOX

Post by AUGE_OHR »

hi,
serge_girard wrote: Thu Sep 25, 2025 9:01 am 2 - Caret position is be moved to the end of the line... I cannot find the function to do this. I will look further.
have a look @c:\hmg.3.4.4\SAMPLES\Controls\TextBox\CARETPOS\demo.prg

Code: Select all

CaretPos := len(VALUE)
have fun
Jimmy
Post Reply