Thread: Click on the listitem into listbox control

1. Click on the listitem into listbox control

In my listbox activeX control has 14 rows . It can hold 14 listitems into it. I like to click on those rows programmatically using coordinates. Any idea for the correct algorithm to accomplish this?

CSMS

2. Re: Click on the listitem into listbox control

Can you get rect of this listbox? If yes, try the next:
[+] void ClickRow(INT iRow)
[] RECT r = ListBox.GetRect()
[] INT xPos = r.xSize/2
[] INT yPos = iRow*r.ySize/14 - r.ySize/28
[] ListBox.Click (1, xPos, yPos)

It will click into the center of needed row.

3. Re: Click on the listitem into listbox control

Hebonpoc,

Thank you very much for solution!

CSMS

4. Re: Click on the listitem into listbox control

Hi Hebonpoc,

If you don't mind would you please explain how you came up with this algorithum?

Thanks,
CSMS

5. Re: Click on the listitem into listbox control

Hi CSMS,
<font class="small">Code:</font><hr /><pre>
[+] void ClickRow(INT iRow)
[ ] RECT r = ListBox.GetRect()
[ ] INT xPos = r.xSize/2
[ ] INT yPos = iRow*r.ySize/14 - r.ySize/28
[ ] ListBox.Click (1, xPos, yPos)
</pre><hr />

1) r.xSize/2 -&gt; gives you the (horizontal) mid position of the list box
2)
a) totally there are 14 rows so each row size can be obtained as r.ySize/14 (if they are symmetric)

b) to get any row's position you need to multiply row size by its number
for ex:
to get 2nd row position-&gt; 2 * r.ySize/14
this gives you the down edge position of a row

c)to get the vertical mid position you need to subtract half of the size of the row
for ex:
2*r.ySize/14 - r.ySize/28, here r.ySize/28 is the half size of the row

I hope this helps you

6. Re: Click on the listitem into listbox control

Hi Krishna Chaitanya,

It's a very good explaination.

Thanks a much.

regards,
CSMS

7. Re: Click on the listitem into listbox control

Hi,

Using Algorithm above works fine. But as it progress down to click on the rows it click for example row 12 instead of row 11.
Looking at closely found out that mouse clicking is going down below center of the rows as it progress. Eventually it click one row ahead then expected.

For example: 1st row it clicks in the center of the row.
2nd row it clicks below center of the row.
3rd row it clicks little more below center of
the row.

Any idea or suggestions would be highly appreciated.

Here is my
RECT r = {0, 0, 1020, 596}
iROW = 14

regards,
CSMS

8. Re: Click on the listitem into listbox control

You have nearly nailed the problem. What do you think the solution is?

9. Re: Click on the listitem into listbox control

CSMS,
I think the reason is Silk doesn't round "/" operation before "*" so there is some additional pixels accumulated.
Try next line (with modifications) instead of old one.

[] INT yPos = iRow*[INT](r.ySize/14) - r.ySize/28

10. Re: Click on the listitem into listbox control

Hebonpoc,

Thank you very much for looking into the solution.

I tried it but problem is still persist.

Thanks,

CSMS

Page 1 of 2 12 Last

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.