Page 1 of 1

EDITBOX or LISTBOX

Posted: Thu Oct 29, 2015 3:09 am
by fchirico
Tengo el siguiente problema:

En un EDITBOX voy mostrando información, renglón por renglón.
El problema es que como lo hago por medio de la PROPIEDAD "VALUE" tengo que mostrarlo todo junto, es decir el mensaje completo, no puedo ir mostrando renglón por renglón.
Entonces decidí usar el CONTROL LISTBOX, y por medio del METODO ADDITEM pude hacerlo perfecto. El problema es que no tiene la propiedad HSCROLL, por lo que las línes se cortan si son muy largas.

Cómo puedo resolver cualquiera de los dos problemas?

Muchas gracias!

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I have the following problem:

In a Editbox I will show information, line by line.
The problem is that as I do through PROPERTY "VALUE" have to show it all together, that is the whole message can not be showing line by line.
Then I decided to use the ListBox, and by the method ADDITEM could make it perfect. The problem is that it has the hscroll property, so that if cut Lines are very long.

How I can solve either problem?

Thank you!

Re: EDITBOX or LISTBOX

Posted: Thu Oct 29, 2015 4:15 am
by Rathinagiri
I don't know I am giving you the expected solution. I might be understood the problem wrong. Excuse me.

If your problem is to cut down the edit box value you can use chr(10) + chr( 13) wherever you want to cut down.

Re: EDITBOX or LISTBOX

Posted: Thu Oct 29, 2015 5:03 am
by srvet_claudio
See this demo:

Code: Select all


#include "hmg.ch"

Function Main

	DEFINE WINDOW Win1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 400 ;
		TITLE 'Hello World!' ;
		MAIN 

		DEFINE LISTBOX ListBox1
			ROW	10
			COL	10
			WIDTH	100
			HEIGHT	110
			ITEMS	{ 'Hello','abcdefghijkl','03','04','05','06','07','08','09','10' }
         FONTNAME "ARIAL"
         FONTSIZE 14
		END LISTBOX


	END WINDOW

   hWnd := Win1.ListBox1.HANDLE
   hFont := _HMG_SYSDATA [ 36 ] [ Win1.ListBox1.INDEX ]
   hDC  := GetDC ( hWnd )
   nWidth := 0
   FOR i := 1 TO Win1.ListBox1.ItemCount
      nLen := GETTEXTWIDTH ( hDC, Win1.ListBox1.Item(i), hFont )
      IF nLen > nWidth
         nWidth := nLen
      ENDIF
   NEXT
   nWidth := nWidth + 10
   ReleaseDC ( hWnd, hDC )
   
   #define WS_HSCROLL 0x00100000
   HMG_ChangeWindowStyle ( hWnd, WS_HSCROLL, NIL, .F., .T. )   // Add Horizontal Scroll Bar

   #define SB_HORZ 0
   SetScrollRange ( hWnd, SB_HORZ, 0, nWidth, .F. )   // Set Horizontal Scroll Bar Range

   #define LB_SETHORIZONTALEXTENT 0x0194
   SendMessage ( hWnd, LB_SETHORIZONTALEXTENT, nWidth, 0 )   // Set the Width in pixels of Horizontal Scroll Bar

   ACTIVATE WINDOW Win1 

Return


Re: EDITBOX or LISTBOX

Posted: Thu Oct 29, 2015 5:52 am
by Rathinagiri
Same solution of Claudio, but with the simpleness of HMG. Can be added as a standard feature also.

Code: Select all


#include "hmg.ch"

Function Main

   DEFINE WINDOW Win1 ;
      AT 0,0 ;
      WIDTH 400 ;
      HEIGHT 400 ;
      TITLE 'Hello World!' ;
      MAIN

      DEFINE LISTBOX ListBox1
         ROW   10
         COL   10
         WIDTH   100
         HEIGHT   110
         ITEMS   { 'Hello','abcdefghijkl','03','04','05','06','07','08','09','10' }
         FONTNAME "ARIAL"
         FONTSIZE 14
      END LISTBOX


   END WINDOW
   
   EnableListBoxHScroll( 'win1', 'listbox1' )

   ACTIVATE WINDOW Win1

Return

function EnableListBoxHScroll( cWindow, cControl )  
   local hWnd := GetControlHandle( cControl, cWindow )
   local hFont := _HMG_SYSDATA [ 36 ] [ GetControlIndex( cControl, cWindow ) ]
   local hDC  := GetDC ( hWnd )
   local nWidth := 0
   local i := 0
   FOR i := 1 TO GetProperty( cWindow, cControl, 'ITEMCOUNT' )
      nLen := GETTEXTWIDTH ( hDC, GetProperty( cWindow, cControl, 'ITEM', i ), hFont )
      IF nLen > nWidth
         nWidth := nLen
      ENDIF
   NEXT
   nWidth := nWidth + 10
   ReleaseDC ( hWnd, hDC )
   
   #define WS_HSCROLL 0x00100000
   HMG_ChangeWindowStyle ( hWnd, WS_HSCROLL, NIL, .F., .T. )   // Add Horizontal Scroll Bar

   #define SB_HORZ 0
   SetScrollRange ( hWnd, SB_HORZ, 0, nWidth, .F. )   // Set Horizontal Scroll Bar Range

   #define LB_SETHORIZONTALEXTENT 0x0194
   SendMessage ( hWnd, LB_SETHORIZONTALEXTENT, nWidth, 0 )   // Set the Width in pixels of Horizontal Scroll Bar

return nil

Re: EDITBOX or LISTBOX

Posted: Thu Oct 29, 2015 12:20 pm
by fchirico
Claudio, Rathi

Gracias por ayudarme.

He probado ambos ejemplos, los dos generan la barra HSCROLL, pero al momento de desplazarme no se desplaza.

Adjunto la pantalla y el segmento del código que muestra las líneas en el LISTBOX.

---------------------------------------------------------------------------------------------------------


Claudio, Rathi

Thanks for helping.

I tried both examples, the two generate the hscroll bar, but when commute does not move.

Deputy screen and code segment showing lines in the listbox.
Captura.JPG
Captura.JPG (48.68 KiB) Viewed 5295 times

Code: Select all

STATIC FUNCTION MuestroRespuesta( a_Respuesta )

local	nIdx		:= 0

if !empty( a_Respuesta )

        FRM_Datos.Muestro_Respuestas.AddItem('====================================' )
	FRM_Datos.Muestro_Respuestas.AddItem('COMIENZA LA VISUALIZACION DE LA RESPUESTA' )
	FRM_Datos.Muestro_Respuestas.AddItem('====================================' )
	FRM_Datos.Muestro_Respuestas.AddItem(CRLF)
        
	for nIdx = 1 to len( a_Respuesta )
		FRM_Datos.Muestro_Respuestas.AddItem(a_Respuesta[ nIdx, 01 ] + ' ---> ' +  a_Respuesta[ nIdx, 02 ])
	next

	FRM_Datos.Muestro_Respuestas.AddItem(CRLF)
	FRM_Datos.Muestro_Respuestas.AddItem('====================================' )
	FRM_Datos.Muestro_Respuestas.AddItem('FINALIZO LA VISUALIZACION DE LA RESPUESTA' )
	FRM_Datos.Muestro_Respuestas.AddItem('====================================' )

else

	FRM_Datos.Muestro_Respuestas.AddItem("****************************************************" )
	FRM_Datos.Muestro_Respuestas.AddItem("     HUBO ALGUN TIPO DE ERROR - NO HAY NADA PARA MOSTRAR       ")
        FRM_Datos.Muestro_Respuestas.AddItem("****************************************************" )
	
endif

RETURN( .T. )

Re: EDITBOX or LISTBOX

Posted: Thu Oct 29, 2015 6:27 pm
by andyglezl
Tal vez...

En un EDITBOX voy mostrando información, renglón por renglón.
El problema es que como lo hago por medio de la PROPIEDAD "VALUE" tengo que mostrarlo todo junto, es decir el mensaje completo, no puedo ir mostrando renglón por renglón.
cTemp += "Resultado ----> R" + chr(10) + chr( 13)
cTemp += "Code ----> 600" + chr(10) + chr( 13)
cTemp += "Msg ----> " + SUBSTR( "La MITAD del mensaje...........................................", 40 ) + chr(10) + chr( 13)
cTemp += " ---------- " + SUBSTR( "La OTRA MITAD del mensaje...........................................", 40 ) + chr(10) + chr( 13)

MainForm.MiTextbox.Value := MainForm.MiTextbox.Value + cTemp

Re: EDITBOX or LISTBOX

Posted: Thu Oct 29, 2015 10:59 pm
by srvet_claudio
Fernando,
El problema es que para que funcione bien hay que modificar el archivo c_listbox.c y agregar el estilo HSCROLL antes de crear el control.

Re: EDITBOX or LISTBOX

Posted: Fri Oct 30, 2015 2:53 am
by fchirico
andyglezl wrote:Tal vez...

cTemp += "Resultado ----> R" + chr(10) + chr( 13)
cTemp += "Code ----> 600" + chr(10) + chr( 13)
cTemp += "Msg ----> " + SUBSTR( "La MITAD del mensaje...........................................", 40 ) + chr(10) + chr( 13)
cTemp += " ---------- " + SUBSTR( "La OTRA MITAD del mensaje...........................................", 40 ) + chr(10) + chr( 13)

MainForm.MiTextbox.Value := MainForm.MiTextbox.Value + cTemp
Gracias Andrés.
Eso es lo que estoy haciendo por el momento, pero quería darle un tratamiento mejor.

Gracias!

Re: EDITBOX or LISTBOX

Posted: Fri Oct 30, 2015 2:56 am
by fchirico
srvet_claudio wrote:Fernando,
El problema es que para que funcione bien hay que modificar el archivo c_listbox.c y agregar el estilo HSCROLL antes de crear el control.
Claudio,

Estuve mirando el archivo .C pero no me doy ideá de cómo hacerlo.
Espero poder contar en la próxima versión con la propiedad HSCROLL.

Muchas gracias por tu ayuda!!!

________________________________________________________________________________________________

Claudio,

I watched the .C file but do not give me idea how to do.
I hope I can count on the next version with hscroll property.

Thank you very much for your help!!!

Re: EDITBOX or LISTBOX

Posted: Fri Oct 30, 2015 9:00 pm
by EduardoLuis
Hi Fernando:

Instead of using Editbox, try with richeditbox, it seems will be more usefull.-
I'll try to make a sample and upload.-
With regards.
Eduardo