Listbox Multiline and no scrool bar

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
meneale
Posts: 51
Joined: Sat Jan 12, 2013 2:05 am
Location: Campinas -SP, Brasil

Listbox Multiline and no scrool bar

Post by meneale »

Hello,
I've got frustrated while trying to get multiline on listbox and disable the scrollbar.. There's a way for that?

Thanks
AMD Phenom II X6 1090T 3.2GHz (OverClock 3.9GHz) | Windows 8.1 Pro 64-bit
4GB DDR3 | GTX 550 Ti 1GB | MSI 880GMA-E35
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Listbox Multiline and no scrool bar

Post by Pablo César »

Seems is not any workable function to disable in ListBox. What I found is to make your own C function which is used for initializate a ListBox like this:

viewtopic.php?p=8442#p8442

and correction (taking off WS_VSCROLL) in this:

viewtopic.php?p=8451#p8451
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Listbox Multiline and no scrool bar

Post by Pablo César »

I found this workable function: HMG_ChangeWindowStyle and I prepare this Demo:

Code: Select all

#include "hmg.ch"

Function Main
DEFINE WINDOW Win1 ;
	AT 0,0 ;
	WIDTH 360 ;
	HEIGHT 180 ;
	TITLE 'Scroll Bar in ListBox' ;
	MAIN 

	DEFINE LISTBOX LIST1
		ROW	10
		COL	10
		WIDTH	100
		HEIGHT	110
		ITEMS	{ '01','02','03','04','05','06','07','08','09','10' }
	END LISTBOX

	DEFINE BUTTON BUTTON1
		ROW	10
		COL	150
		CAPTION	'Disable Vertical Scroll Bar'
		ACTION	Scroll_OFF()
		WIDTH	150
	END BUTTON
	
	DEFINE BUTTON BUTTON2
		ROW	40
		COL	150
		CAPTION	'Enable Vertical Scroll Bar'
		ACTION	Scroll_ON()
		WIDTH	150
	END BUTTON

END WINDOW
CENTER WINDOW Win1
ACTIVATE WINDOW Win1
Return Nil

Function Scroll_OFF()
Local hWnd := GetControlHandle ("LIST1","Win1")
HMG_ChangeWindowStyle ( hWnd, NIL, WS_VSCROLL, .F. )
Return Nil

Function Scroll_ON()
Local hWnd := GetControlHandle ("LIST1","Win1")
// HMG_ChangeWindowStyle ( hWnd, NIL, WS_VSCROLL, .T. ) // wrong
HMG_ChangeWindowStyle ( hWnd, WS_VSCROLL, NIL, .F. )
Return Nil
This HMG_ChangeWindowStyle function is basically for window/forms, but in this Demo the DISABLE option is working :!: :D

P.S. Code has been re-edited and corrected
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Listbox Multiline and no scrool bar

Post by Pablo César »

I do not know why enable option doesn't works ! :(
Attachments
Screen.PNG
Screen.PNG (21.42 KiB) Viewed 5319 times
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Listbox Multiline and no scrool bar

Post by bpd2000 »

Pablo César wrote:I do not know why enable option doesn't works ! :(
to enable option Use code : HMG_ChangeWindowStyle ( hWnd, WS_VSCROLL, NIL, .F. )
BPD
Convert Dream into Reality through HMG
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Listbox Multiline and no scrool bar

Post by Pablo César »

bpd2000 wrote:
Pablo César wrote:I do not know why enable option doesn't works ! :(
to enable option Use code : HMG_ChangeWindowStyle ( hWnd, WS_VSCROLL, NIL, .F. )
Thank you Dave, you are right !

I made a mistake to put in wrong way as HMG_ChangeWindowStyle ( hWnd, NIL, WS_VSCROLL, .T. )
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
meneale
Posts: 51
Joined: Sat Jan 12, 2013 2:05 am
Location: Campinas -SP, Brasil

Re: Listbox Multiline and no scrool bar

Post by meneale »

Oh, thanks,
It Works very well, but i mainly need a listbox with multiline (I mean 2 or more lines in a single item) like a text with CRLF between each line
AMD Phenom II X6 1090T 3.2GHz (OverClock 3.9GHz) | Windows 8.1 Pro 64-bit
4GB DDR3 | GTX 550 Ti 1GB | MSI 880GMA-E35
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Listbox Multiline and no scrool bar

Post by Pablo César »

meneale wrote:Oh, thanks,
It Works very well, but i mainly need a listbox with multiline (I mean 2 or more lines in a single item) like a text with CRLF between each line
You mean 2 columns, right ?

If is the case, try to concatenate each item and use Courier New (monospaced font).
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
meneale
Posts: 51
Joined: Sat Jan 12, 2013 2:05 am
Location: Campinas -SP, Brasil

Re: Listbox Multiline and no scrool bar

Post by meneale »

Então Pablo, não queria duas colunas e sim duas linhas em um único item, como isto:
Image
Já tentei usando CHR(13) + CHR(10) entre cada linha mas quando compilado o programa exclui o CRLF.
AMD Phenom II X6 1090T 3.2GHz (OverClock 3.9GHz) | Windows 8.1 Pro 64-bit
4GB DDR3 | GTX 550 Ti 1GB | MSI 880GMA-E35
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Listbox Multiline and no scrool bar

Post by Pablo César »

Ahh sim entendi. Não tem esta opção o nosso ListBox ao menos que seja modificado a função C INITLISTBOX e pelo que pesquisei o ListBox Style precisaria de LBS_OWNERDRAWVARIABLE
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply