"Zero-based index"

Started by
2 comments, last by dirkduck 20 years, 8 months ago
Hi everyone. I''ve been looking around MSDN at some messages that add strings to combo/list boxes...etc. Anyways, msot of them say to be given a ''zero-based'' index at which to insert the new item. As I understand it, its just the position, with ''0'' being the first item..etc. The thing I don''t get is that on some: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listboxes/listboxreference/listboxmessages/lb_insertstring.asp It asks for the zero-based index, but if the parameter is ''1'', it is added to the end. How would you add an item to the second slot (1) if setting the parameter to 1 adds it to the end? Thanks.
http://www.labino.net
Advertisement
I believe that it''s a typo, and that it''s supposed to read -1. Experiment and see.
index
Value of wParam. Specifies the zero-based index of the position at which to insert the string. If this parameter is –1, the string is added to the end of the list.

a typo. its correct in the local msdn of vs6..

"take a look around" - limp bizkit
www.google.com
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

From my MSDN on CD (version 6 of MSVC):

LB_INSERTSTRING
wParam = (WPARAM) index; // item index
lParam = (LPARAM) (LPCTSTR) lpsz; // address of string to insert

Parameters
index
Value of wParam. Specifies the zero-based index of the position at which to insert the string. If this parameter is –1, the string is added to the end of the list.
Windows 95 and Windows 98: The wParam parameter is limited to 16-bit values. This means list boxes cannot contain more than 32,767 items. Although the number of items is restricted, the total size in bytes of the items in a list box is limited only by available memory.

lpsz
Value of lParam. Pointer to the null-terminated string to be inserted.
If you create the list box with an owner-drawn style but without the LBS_HASSTRINGS style, the value of the lpsz parameter is stored as item data instead of the string it would otherwise point to. You can send the LB_GETITEMDATA and LB_SETITEMDATA messages to retrieve or modify the item data.


As you can see, it is supposed to say -1, not 1.

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

This topic is closed to new replies.

Advertisement