- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to be able to select an item from a combo box list and immediately display some information about that item in another edit box. The message CBN_SELCHANGE appears from my reading to be the one to work with, yet on responding to it, GetDlgItemText returns nothing from the edit box part of the combo box. I guess this is because, at the time of respnding to this message, the edit box part of the combo has not yet been updated.
So how can I do this?
With many thanks in advance
Mike
So how can I do this?
With many thanks in advance
Mike
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can probably use CBN_EDITCHANGE or CBN_EDITUPDATE instead. I don't think there's a straightforward way to determine whether it occurred due to typing in the edit portion or due to selection from the list. If that's important to distinguish (sounds like it is), on CBN_EDITxxx you could:
1) SendMessage(CB_FINDSTRINGEXACT) to verify that the typed string exists in the list portion, or
2) Set a logical variable (e.g. bWasSelected) on CBN_SELCHANGE and test it, on CBN_EDITxxx (which comes immediately after), then clear it. If it was set, that means the change is due to selection.
Also, check out CB_SELENDOK. I'm not sure whether it's applicable -- the docs are a bit unclear.
Jugoslav
1) SendMessage(CB_FINDSTRINGEXACT) to verify that the typed string exists in the list portion, or
2) Set a logical variable (e.g. bWasSelected) on CBN_SELCHANGE and test it, on CBN_EDITxxx (which comes immediately after), then clear it. If it was set, that means the change is due to selection.
Also, check out CB_SELENDOK. I'm not sure whether it's applicable -- the docs are a bit unclear.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jugoslav,
Thanks for your reply. I think I have tried all the options and none of them works. It doesn't matter to me whether the user types in an item, or selects it from the list part of the combo box - in either case I want some other information to be displayed in different edit box alongside. In the case of the user typing the item, both CBN_EDITCHANGE and CBN_EDITUPDATE do the same thing - I can use GetDlgItemText to read what's been typed in and respond accordingly. But when the user selects the item from the combo list, all messages seem to be sent before the item appears in the edit box part, so I can't read it. I need to be able to read the item directly from the list box part. Any suggestions?
Many thanks again,
Mike
Thanks for your reply. I think I have tried all the options and none of them works. It doesn't matter to me whether the user types in an item, or selects it from the list part of the combo box - in either case I want some other information to be displayed in different edit box alongside. In the case of the user typing the item, both CBN_EDITCHANGE and CBN_EDITUPDATE do the same thing - I can use GetDlgItemText to read what's been typed in and respond accordingly. But when the user selects the item from the combo list, all messages seem to be sent before the item appears in the edit box part, so I can't read it. I need to be able to read the item directly from the list box part. Any suggestions?
Many thanks again,
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
True, I've just verified that -- and how stupid it is.
FWIW, attached is a workspace I used for testing. The workaround seems to be to handle CBN_SELENDOK and write the selected string yourself manually into the edit portion "prematurely". See inline comments on CBN_SELENDOK.
Jugoslav
FWIW, attached is a workspace I used for testing. The workaround seems to be to handle CBN_SELENDOK and write the selected string yourself manually into the edit portion "prematurely". See inline comments on CBN_SELENDOK.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jugoslav,
Thanks for confirming the "stupid" combo box behaviour. I'd love to be able to download your workaround, but unfortunately, when I try, I get an error of "zero size". Over to you, but thanks again.
Mike
Thanks for confirming the "stupid" combo box behaviour. I'd love to be able to download your workaround, but unfortunately, when I try, I get an error of "zero size". Over to you, but thanks again.
Mike
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page