Using the New DLCall Function to call the Win API SendMessage Function we can 
Select and DeSelect a ListBox's items in a few lines of code without iterating 
through the entire list.  Here's How:

First, put the following Declaration where it will be called ONLY ONCE during a 
given RBase User Session, likely in a StartUp File of some kind. (Yes the 
Pluses are line continuation so the news reader wouldn't wrap it)

-- Declaration of SendMessage:

StdCall function 'SendMessageA' +
alias 'SendMessage' +
(Integer, Integer, Integer, Integer) : Integer



Then on a form put a ListBox of some kind although I only tested it with a 
variable User Defined ListBox.
assign it a Component ID (I used LBList )

in the OnAfterStart EEP , Set the ListBox to MultiSelect:

PROPERTY lblist multiselect 'true'

Put a couple of buttons on the form, One to Select All and one To DeSelect All

The Code for Select ALL:

--Begin

SET VAR vhnd TEXT = NULL
GETPROPERTY lblist handle vhnd
SET VAR vhwnd INTEGER = (INT(.vhnd))
SET VAR vret INTEGER = NULL
SET VAR lb_setsel INTEGER = 389

SET VAR vlparam INTEGER = -1
--SET VAR vbool INTEGER = 0 -- false removes Selected
SET VAR vbool INTEGER = 1 -- true Sets Selected
SET VAR vret = +
(dlcall('User32', 'SendMessageA' , vlparam, vbool, lb_setsel, vhwnd))

RETURN

--End

The Code for DeSelect ALL:

--Begin

SET VAR vhnd TEXT = NULL
GETPROPERTY lblist handle vhnd
SET VAR vhwnd INTEGER = (INT(.vhnd))
SET VAR vret INTEGER = NULL
SET VAR lb_setsel INTEGER = 389

SET VAR vlparam INTEGER = -1
SET VAR vbool INTEGER = 0 -- false Removes Selected
--set var vBool integer = 1 -- true Sets Selected
SET VAR vret = +
(dlcall('User32', 'SendMessageA' , vlparam, vbool, lb_setsel, vhwnd))

RETURN

--End

That's All there is to it.  If you want to download a fully functioning demo, 
here is the link (Just remember to execute the delcaration of the SendMessage 
Function prior to running the form)

www.byerley.net/KT_ListBox.zip






Mike Byerley

"We Cannot Approach or Discuss 'YES', Until we
Have A Complete And Thorough Understanding Of 'NO'" 

--- RBASE-L
================================================
TO POST A MESSAGE TO ALL MEMBERS:
Send a plain text email to [email protected]

(Don't use any of these words as your Subject:
INTRO, SUBSCRIBE, UNSUBSCRIBE, SEARCH,
REMOVE, SUSPEND, RESUME, DIGEST, RESEND, HELP)
================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: INTRO
================================================
TO UNSUBSCRIBE: 
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: UNSUBSCRIBE
================================================
TO SEARCH ARCHIVES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: SEARCH-n
(where n is the number of days). In the message body, 
place any 
text to search for.
================================================


Reply via email to