Hello,

I having a little bit problem with list boxes. I can't get it to show a WORKING hscroll bar.. :\

I set the style and everything, but it doesn't do it automatically. What should I use to do it? I thought of MEASUREITEM, but it seems to be for owner drawing only... or maybe is something I forgot... I didn't find examples here about this, and...
I am using what I found here already, bazik... ;)

It seems like Ill have to use LB_SETHORIZONTALEXTENT, but how do I know the value needed?

?-\

Ill post here the meaningfull code I have now:




ListBoxProc proc hCtl :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

LOCAL IndexItem :DWORD
LOCAL Buffer[32] :BYTE ;max item length!!!!!


;when the user double clicks a item, show a
;message box with the text of that item, plus add a
;new item to the list. But the hscrool bar still disabled,
;even the item being larger then its width...
.if uMsg == WM_LBUTTONDBLCLK
jmp DoIt
(...)
DoIt:

(...)
invoke MessageBox,hWnd,ADDR Buffer,ADDR CurSel2,MB_OK
.endif

invoke SendMessage,hList2,LB_ADDSTRING,0,ADDR lItem2

EndDo:

invoke CallWindowProc,lpLstBox1,hCtl,uMsg,wParam,lParam

ret

ListBoxProc endp
==============



ListBox proc a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,hParent:DWORD,ID:DWORD

szText lstBox,"LISTBOX"

invoke CreateWindowEx,WS_EX_CLIENTEDGE or WS_EX_CONTROLPARENT,\
ADDR lstBox,0,
WS_VSCROLL or WS_HSCROLL or \ ;HERE!
WS_VISIBLE or \
WS_BORDER or WS_CHILD or \
LBS_HASSTRINGS or LBS_NOINTEGRALHEIGHT or \
LBS_DISABLENOSCROLL,
;show scroll bar always, disabled if need (???)

a,b,wd,ht,hParent,ID,hInstance,NULL

ret

ListBox endp
Posted on 2002-11-28 09:29:24 by wicr0s0ft
wicr0s0ft,
This problem of your's cannot be resolved(by me anyway). I tested the exact
code you wrote below and after the MessageBox popsup, another item is
added to the list. And when the list contains non-visible items the Horizontal-
scrollbar is visible(not-grayed).

So it's kinda hard to solve your problem when the code doesnt have one. :eek:
Posted on 2002-11-28 10:43:04 by natas
How is that possible?? I recompiled it now, and still the horizontal scroll bar doens't give signs of life... the point of adding items is to see if the list box just needed an "update" to force it redrawing correctly. Result was it did only for the vertical bar... :\

This is not only at home (win98se) but here at work too (winnt40).

What system are you using, natas?

I made a screen shot of it... it is attached.

The sources I used to compile the last time are attached too... try to run MY executable fisrt, as it should not have the hscroll bar working. ;)

Atention appreciated, natas! :)

...
Posted on 2002-11-28 15:13:58 by wicr0s0ft
wicr0s0ft, I was actually thinking that Horizontal was Vertical for some
wierd reason. It's like having a episode of 'X-Files' in my head today. ( :grin: )

Anyway, you have to calculate the size in pixels of the new horizontalscroll width.
In order to correctly use the horizontal scrollbar. Searching Microsoft provided
me with a 16-bit version of howto do this(among others). Actually you only haveto do
some small conversions here and there to make it work. So it'll give you something todo. ( :) )
http://support.microsoft.com/default.aspx?scid=kb;en-us;66370

And if you want more examples there are tons of examples if you search using
google with the word 'LB_SETHORIZONTALEXTENT'.

Have phun!
Posted on 2002-11-28 19:37:00 by natas
Since I was bored I decided to whip up some source code for you'r
viewing pleasure. But I would advise you to read a little about it,
so that you know what it does. Enjoy!
[color=sienna]

...
LOCAL hDC :DWORD
LOCAL rcText :RECT
...
invoke SendMessage,hList2,LB_ADDSTRING,0,ADDR Buffer

invoke GetDC,hList2
mov hDC,eax
invoke SendMessage,hList2, WM_GETFONT,0,0
invoke SelectObject,hDC, eax

invoke lstrlen,addr Buffer
invoke DrawText,hDC,addr Buffer,eax,addr rcText, DT_CALCRECT

invoke GetSystemMetrics,SM_CXVSCROLL
add eax,rcText.right

invoke SendMessage,hList2, LB_SETHORIZONTALEXTENT,eax,0
invoke DeleteDC,hDC

EndDo:
...
[/color]

Posted on 2002-11-29 07:07:14 by natas
Thanks a lot, natas!

And if you are bored of doing nothing, I am tossed with too much things to do (many involving programming in win32asm :) ... do you want some? ;)
Posted on 2002-12-02 15:06:46 by wicr0s0ft

Thanks a lot, natas!
And if you are bored of doing nothing, I am tossed with too much things to do (many involving programming in win32asm :) ... do you want some? ;)

Well I tend to get bored with the stuff im programming. ( :eek: ) So I use this board
as a little break to getaway when I have a 'brain-lock'. That doesnt mean
I dont have enough todo myself. :alright:
Posted on 2002-12-02 15:28:44 by natas