Programmatically click on list box item?

A quick search of the archives did not reveal an answer.  Is it possible to simulate a mouse click on an item in a  list box control?  I need to get the list box procedure to execute with the desired selection.  I can create the list box structure, fill in needed elements and call the procedure directly.  Just wondering if there is an easier way.

Thanks,

Jeff 

Hi,

Can you separate the listbox control into two pieces, one having the interface and then passing a string for the item and then a second function that handles the action?  That way you can short cut the string selection via you code.

 

Andy

The basic answer to your question is No.

You can set the selection programmatically by setting bit 1 in the selwave.

I would recommend against directly calling the action procedure. Refactor your code so that the code you need to run is in its own function. Call that code from the action procedure, and also from wherever it is that you need to do it programmatically.

Thanks Andy & John.  Sounds like you are both suggesting the same solution. 

Actually, looking at my code, I already had split the code into the list box action function which then calls the worker function.  For the sake of convenience, I pass the list box structure (WMListboxAction) to my worker function.  I could easily break out the few necessary structure elements into separate input parameters to pass to the worker function.

@John - Would you recommend passing only the needed parameters instead of the entire structure?  In the work around that I wrote today, I created the structure in the other function, filled in the few needed elements and passed that to the worker function.

That certainly works. My personal style would be (usually) to just pass the needed parameters. It makes it easier to read the code.