EDITBOX or LISTBOX

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
fchirico
Posts: 324
Joined: Sat Aug 23, 2008 11:27 pm
Location: Argentina

EDITBOX or LISTBOX

Post 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!
Saludos, Fernando Chirico.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: EDITBOX or LISTBOX

Post 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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: EDITBOX or LISTBOX

Post 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

Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: EDITBOX or LISTBOX

Post 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
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
fchirico
Posts: 324
Joined: Sat Aug 23, 2008 11:27 pm
Location: Argentina

Re: EDITBOX or LISTBOX

Post 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 5210 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. )
Saludos, Fernando Chirico.
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: EDITBOX or LISTBOX

Post 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
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: EDITBOX or LISTBOX

Post 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.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
fchirico
Posts: 324
Joined: Sat Aug 23, 2008 11:27 pm
Location: Argentina

Re: EDITBOX or LISTBOX

Post 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!
Saludos, Fernando Chirico.
User avatar
fchirico
Posts: 324
Joined: Sat Aug 23, 2008 11:27 pm
Location: Argentina

Re: EDITBOX or LISTBOX

Post 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!!!
Saludos, Fernando Chirico.
EduardoLuis
Posts: 682
Joined: Tue Jun 04, 2013 6:33 pm
Location: Argentina

Re: EDITBOX or LISTBOX

Post 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
Post Reply