# Help with HtmlListBox.hit\_test and painting on DC

**URL:** <https://www.ruby-forum.com/t/help-with-htmllistbox-hit-test-and-painting-on-dc/179467>\
**Category:** wxRuby\
**Created:** [November 25, 2009, 5:40pm UTC](https://www.ruby-forum.com/t/help-with-htmllistbox-hit-test-and-painting-on-dc/179467 "2009-11-25T17:40:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [November 25, 2009, 5:40pm UTC](https://www.ruby-forum.com/t/help-with-htmllistbox-hit-test-and-painting-on-dc/179467/1 "2009-11-25T17:40:23Z")

</div>

I need help getting this code to work.

I am having trouble getting the hit\_test to work. It seems to be true  
even when the mouse is not over the control (specifically to the right  
of the control).

case  
when (ht = @htmlctrl.hit\_test(@htmlctrl.screen\_to\_client  
evt.get\_position)) != NOT\_FOUND  
# …

I am also trying to paint on a DC. I have attached an example of this.

If you need any additional information please ask.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [November 25, 2009, 6:27pm UTC](https://www.ruby-forum.com/t/help-with-htmllistbox-hit-test-and-painting-on-dc/179467/2 "2009-11-25T18:27:35Z")

</div>

It seems I forgot to mention that the issue with the DC code is that it  
draws under the previous image when the window is resized.

---

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [November 25, 2009, 9:50pm UTC](https://www.ruby-forum.com/t/help-with-htmllistbox-hit-test-and-painting-on-dc/179467/3 "2009-11-25T21:50:27Z")

</div>

OK. I found a solution for the first issue.  
I still need help with painting on a DC.

I fixed it by checking the x position.

case  
when (ht = @htmlctrl.hit\_test(@htmlctrl.screen\_to\_client  
evt.get\_position)) != NOT\_FOUND &&  
@htmlctrl.screen\_to\_client(evt.get\_position).x \<  
@htmlctrl.get\_client\_size.width  
# …
