To set how many pixels $wrap() should work with, you might want to try $window().dw (or .dh); take a further look at the help file.
P.S.: since the .dw and .dh properties are related only to non-listbox text @windows, you could temporarily use a hidden, non-listbox one with the same dimensions as the listbox one, then get its .dw and .dh dimensions.
Doing this, though, you'd wrap lines with some offset to the left, because that hidden window would calculate its display width subtracting the scrollbar width, something that listbox windows don't have.
A solution for that (that I know of) would be using a DLL, one that gets the scrollbar width for you, checking your OS settings etc. I'm sure there is one at
www.mircscripts.org, I think it was made by dohcan, but I can't remember its name, and I don't know if it'll load properly on the latest mIRC version (it's a little old). Do some search there if you want it.