Log in

View Full Version : Destruction of Listbox Hscroll?!


Manko
September 29th, 2002, 09:11
In the resources this particular Listbox has both VScroll and HScroll but when I use the program it doesn't have the Hscroll.
I am guessing it destroys it, or it doesnt include it if it's just a template. I have no idea what the code for this would look like.
How does one go about dostroying/adding HScroll on an existing dialog?

/Manko

comrade
September 29th, 2002, 16:17
ListBox WS_HSCROLL is not automatically added, and program should manually tell the listbox the extent of the horizontal scrollbar. Probably that style was just a mistake by the programmers.

Kayaker
September 29th, 2002, 17:30
Hi

I have a feeling this is a bit of a bug with listboxes, or maybe it's by design, the vertical scroll seems automatic but the horizontal scroll needs to be controlled by the LB_SETHORIZONTALEXTENT message.

An application sends an LB_SETHORIZONTALEXTENT message to set the width, in pixels, by which a list box can be scrolled horizontally (the scrollable width). If the width of the list box is smaller than this value, the horizontal scroll bar horizontally scrolls items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden. To respond to the LB_SETHORIZONTALEXTENT message, the list box must have been defined with the WS_HSCROLL style.


I've seen the same thing in the APISpy32 input and output dialog boxes for example - even if the text is wider than the listbox, the HScrollbar doesn't appear. One solution might be to patch in a SendMessage call to the dialog box with LB_SETHORIZONTALEXTENT, and wParam set to a small width (or maybe the width of the listbox), then the scrollbar should appear. The easiest solution to the main problem however, if it was feasible, might be to increase the width of the dialog box, and then increase the width of the listbox so the majority of the text wasn't cut off. This is what I did (via a resource editor) with APISpy32 because I was so annoyed with the tiny size of the output dialog.

Kayaker

Manko
September 29th, 2002, 22:59
Quote:
Originally posted by Kayaker
Hi

I have a feeling this is a bit of a bug with listboxes, or maybe it's by design, the vertical scroll seems automatic but the horizontal scroll needs to be controlled by the LB_SETHORIZONTALEXTENT message.

I've seen the same thing in the APISpy32 input and output dialog boxes for example - even if the text is wider than the listbox, the HScrollbar doesn't appear. One solution might be to patch in a SendMessage call to the dialog box with LB_SETHORIZONTALEXTENT, and wParam set to a small width (or maybe the width of the listbox), then the scrollbar should appear. The easiest solution to the main problem however, if it was feasible, might be to increase the width of the dialog box, and then increase the width of the listbox so the majority of the text wasn't cut off. This is what I did (via a resource editor) with APISpy32 because I was so annoyed with the tiny size of the output dialog.

Kayaker


Yup, ApiSpy32...

Actually, I did it the same way but often the params extend beyond the maximum new width.
It felt like a quick and dirty fix rather than a proper reverseing.
I suspected the author had done something tricky, a newbie such as myself wouldn't understand.

'Tis why I'm at it again...

Thanks alot for the help! It seems it would work.

It should be pretty straightforward, including a large LB_SETHORIZONTALEXTENT somewhere...

Oh, well... not tonight, anyway...

Thanks again!

/Manko

Snatch
September 29th, 2002, 23:25
Well you might first go to a resource viewer and find the listbox and see its styles assuming its static(ya im a dynamic freak I dont like having fixed resources ). Anyway then you can search with IDA for immediate values of LM_XXX. This works well. You will land near or in the message handler. If it is MFC or whatever then you just need to find the rdata pointer table for the CListBox. You have lots of options in disassembly to figure out what is going on. Just have WinUser.h ready to look up the ListBox message or style numeric values.

Snatch