News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Number Of Items In Combobox

Started by EarlCrapstone, October 27, 2005, 10:43:39 PM

Previous topic - Next topic

EarlCrapstone

Hello everyone! I need to find out how many items there are in a combobox. There is a simple message you can sedn to a listbox to get this, but there doesn't seem to be one for a combobox. Is there any easier way to get this without going through every item and seeing if it exists and then incrementing a counter?


EarlCrapstone

Thank you. it works, but for some reason in Radasm it didn't show up in the little drop down box...

EarlCrapstone

I have another question relating to a listbox. When you do LB_GETCURSEL, even if nothing is selected, it returns 0 so you don't know if the first item is selected or no item is selected. Is there any way to tell if something is actually selected?

Tedd

QuoteThe return value is the zero-based index of the currently selected item or of the base item in a multiple selection.
If there is no selection, the return value is LB_ERR.

So a return value of zero means the first item in the list.
If there are no items selected, the return value is LB_ERR (-1)
No snowflake in an avalanche feels responsible.

EarlCrapstone

Even when the cursor is in an editbox or something, it still returns 0 not -1.

Tedd

The 'current selection' is the item currecntly selected - the one that is currently shown as 'chosen'
So it makes no difference where the cursor is.
But from this, I'm guessing you're thinking of the item that is currently hilighted? (the one the mouse pointer is currently over?)

[Actually, I don't see how you could have no selection, since one of the items will always be selected; first by default.]
No snowflake in an avalanche feels responsible.

EarlCrapstone

I didn't mean the one the cursor is over, I meant the one that is highlighted. But if the default is the first item, I guess there is no solution to my problem. But if the first is default, why do they even have a negative return value? Does it return that if there are no items?

Tedd

Quote from: EarlCrapstone on November 01, 2005, 11:25:52 PM
I didn't mean the one the cursor is over, I meant the one that is highlighted. But if the default is the first item, I guess there is no solution to my problem.
Your probem is that you don't know if the user has 'changed' the selection?
Well, you could assume that whatever is currently selected is what they really wanted - so there was no need to change it. Or, I suppose you could put a dummy string as the first one e.g. "(no selection)" and then if that is still selected, the user didn't change it.

QuoteBut if the first is default, why do they even have a negative return value? Does it return that if there are no items?
I was wondering the same thing. It may just be for when there are no items; or I could be wrong and the default is none unless you specifically set a selection just after creation. Try it and see :wink
No snowflake in an avalanche feels responsible.

EarlCrapstone

I tried setting the selecting to -1, which in theory would tell it that nothing is selected, but that didn't work either. I guess I'll just have to deal with it. it's not a huge deal.

I do have one last question though. Is there a string split function in ASM similar to the VB or PHP function? I tried searching google and many other forums, but I couldn't find anything. I just need to split a string at a certain character like a ",".

Tedd

Not quite. The value of -1 indicates an error, not no selection. It's returned in the case of getcursel when there's no selection, because that is an error condition.
If you want to have 'no slection' (blank) then I think you could insert an empty string (you may possibly have to make it contain a space) as the first element and have that as the default selection.

I don't think there's an api function to do 'split' but there may be one floating around that someone has already done. It's not all that difficult to do yourself - just check each character of the string until you reach the one you're looking for (or the end) and then copy from the start of the string to the character before the one found to the supplied buffer, and terminate it with a null :wink
Of course, doing a fuill split for every occurence, returning multiple strings is a little more difficult. But there's no reason why you couldn't call the single-split mutliple times, continuing from the end of the previous find.
No snowflake in an avalanche feels responsible.

MichaelW

There is the CRT function strtok, and I think donkey had an ASM version in his string library.

eschew obfuscation

EarlCrapstone

I just searched this forum for strtok and came up with this:

http://www.masmforum.com/simple/index.php?topic=515.msg3423#msg3423

I think the file he attached might work. I'll try it and let you know how it goes.