ListBox Multiselect value - Read only?

Moderator: Rathinagiri

Post Reply
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

ListBox Multiselect value - Read only?

Post by Rathinagiri »

Multiselect enabled ListBox can not be initialized or set to user defined value. Is that only a read-only property?

Consider this small sample.

Code: Select all

/*
* HMG Hello World Demo
* (c) 2002-2004 Roberto Lopez <mail.box.hmg@gmail.com>
*/

#include "hmg.ch"

Function Main

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

		DEFINE LISTBOX LIST1
			ROW	10
			COL	10
			WIDTH	100
			HEIGHT	110
			ITEMS	{ '01','02','03','04','05','06','07','08','09','10' }
			multiselect .t.
		END LISTBOX
		define button click
		  row 10
		  col 120
		  width 50
		  caption "Click"
		  action 	Win1.LIST1.value := {1,2}
    end button 


	END WINDOW
	Win1.LIST1.value := {1,2}

	ACTIVATE WINDOW Win1 

Return


I want to show the listbox with the first and second item, selected.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: ListBox Multiselect value - Read only?

Post by Roberto Lopez »

rathinagiri wrote:Multiselect enabled ListBox can not be initialized or set to user defined value. Is that only a read-only property?

Consider this small sample.

Code: Select all

/*
* HMG Hello World Demo
* (c) 2002-2004 Roberto Lopez <mail.box.hmg@gmail.com>
*/

#include "hmg.ch"

Function Main

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

		DEFINE LISTBOX LIST1
			ROW	10
			COL	10
			WIDTH	100
			HEIGHT	110
			ITEMS	{ '01','02','03','04','05','06','07','08','09','10' }
			multiselect .t.
		END LISTBOX
		define button click
		  row 10
		  col 120
		  width 50
		  caption "Click"
		  action 	Win1.LIST1.value := {1,2}
    end button 


	END WINDOW
	Win1.LIST1.value := {1,2}

	ACTIVATE WINDOW Win1 

Return


I want to show the listbox with the first and second item, selected.
I'll check it.

Thanks for reporting.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
gfilatov
Posts: 1057
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: ListBox Multiselect value - Read only?

Post by gfilatov »

Hi Roberto,

Please be so kind to update the following C-function in the file c_listbox.c:

Code: Select all

HB_FUNC( LISTBOXSETMULTISEL )
{
   PHB_ITEM wArray;

   HWND     hwnd = ( HWND ) hb_parnl( 1 );

   int      i;
   int      n;
   int      l;

   wArray = hb_param( 2, HB_IT_ARRAY );

   l = hb_parinfa( 2, 0 ) - 1;

   n = SendMessage( hwnd, LB_GETCOUNT, 0, 0 );

   // CLEAR CURRENT SELECTIONS

   for( i = 0; i < n; i++ )
   {
      SendMessage( hwnd, LB_SETSEL, (WPARAM) (0), (LPARAM) i );
   }

   // SET NEW SELECTIONS

   for( i = 0; i <= l; i++ )
   {
      SendMessage( hwnd, LB_SETSEL, (WPARAM) (1), (LPARAM) (hb_arrayGetNI(wArray, i + 1)) - 1 );
   }
}
Hope that helps 8-)
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: ListBox Multiselect value - Read only?

Post by Roberto Lopez »

gfilatov wrote:Hi Roberto,

Please be so kind to update the following C-function in the file c_listbox.c:
<...>
Thanks Grigory!!!

I've come here to inform Rathi that I'm sure that is a Harbour compatibility problem related with internal changes introduced in 2.0.

You saved me a lot of researching time...

Thanks again!!!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: ListBox Multiselect value - Read only?

Post by Roberto Lopez »

rathinagiri wrote:Multiselect enabled ListBox can not be initialized or set to user defined value. Is that only a read-only property?
<...>
Attached is a fixed libhmg.a.
Attachments
libhmg3034a.rar
(195.09 KiB) Downloaded 313 times
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: ListBox Multiselect value - Read only?

Post by esgici »

Thanks Roberto

Best regards

--

Esgici
Viva INTERNATIONAL HMG :D
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: ListBox Multiselect value - Read only?

Post by Rathinagiri »

Thanks a lot Roberto for this quick fix. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
gfilatov
Posts: 1057
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: ListBox Multiselect value - Read only?

Post by gfilatov »

Roberto Lopez wrote: Thanks Grigory!!!

I've come here to inform Rathi that I'm sure that is a Harbour compatibility problem related with internal changes introduced in 2.0.

You saved me a lot of researching time...

Thanks again!!!
Hello Roberto,

I'm glad to help 8-)
Your time is very important for HMG community :D
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: ListBox Multiselect value - Read only?

Post by Roberto Lopez »

gfilatov wrote:
Roberto Lopez wrote: Thanks Grigory!!!

I've come here to inform Rathi that I'm sure that is a Harbour compatibility problem related with internal changes introduced in 2.0.

You saved me a lot of researching time...

Thanks again!!!
Hello Roberto,

I'm glad to help 8-)
Your time is very important for HMG community :D
Sadly I'll must spent some time now, trying to understand the true meaning of your answer ;)
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply