Page 1 of 1
ListBox Multiselect value - Read only?
Posted: Tue May 25, 2010 3:38 pm
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.
Re: ListBox Multiselect value - Read only?
Posted: Tue May 25, 2010 5:04 pm
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.
Re: ListBox Multiselect value - Read only?
Posted: Tue May 25, 2010 6:18 pm
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

Re: ListBox Multiselect value - Read only?
Posted: Tue May 25, 2010 10:51 pm
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!!!
Re: ListBox Multiselect value - Read only?
Posted: Tue May 25, 2010 10:56 pm
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.
Re: ListBox Multiselect value - Read only?
Posted: Tue May 25, 2010 11:29 pm
by esgici
Thanks Roberto
Best regards
--
Esgici
Re: ListBox Multiselect value - Read only?
Posted: Wed May 26, 2010 1:18 am
by Rathinagiri
Thanks a lot Roberto for this quick fix.

Re: ListBox Multiselect value - Read only?
Posted: Wed May 26, 2010 12:57 pm
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
Your time is very important for HMG community

Re: ListBox Multiselect value - Read only?
Posted: Thu May 27, 2010 12:48 am
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
Your time is very important for HMG community

Sadly I'll must spent some time now, trying to understand the true meaning of your answer
