-
August 30th, 2005, 06:07 PM
#1
Extend width of Drop-down list of Combo Box
The diablog window size is fixed, and the width of the Combo Box is fixed as well. But some of the drop-down list items contain long strings. How can I just widen the drop-down part of the combo box but keep the fixed size of the combo box?
Thanks!!!
-
August 31st, 2005, 06:06 AM
#2
Re: Extend width of Drop-down list of Combo Box
CB_SETHORIZONTALEXTENT:
Originally Posted by MSDN
An application sends the CB_SETHORIZONTALEXTENT message to set the width, in pixels, by which a list box can be scrolled horizontally (the scrollable width). If the width of the list box is smaller than this value, the horizontal scroll bar horizontally scrolls items in the list box. If the width of the list box is equal to or greater than this value, the horizontal scroll bar is hidden or, if the combo box has the CBS_DISABLENOSCROLL style, disabled.
This should do your work.
-
August 31st, 2005, 06:19 AM
#3
Re: Extend width of Drop-down list of Combo Box
You could also try following:
Code:
::SendMessage(yourComboBoxHandle, CB_SETDROPPEDWIDTH, nWidth, 0);
Hope this helps
Hob
EDIT: Removed MFC specific code
Last edited by Hobson; August 31st, 2005 at 07:02 AM.
B+!
'There is no cat' - A. Einstein
Use [code] [/code] tags!
Did YOU share your photo with us at CG Members photo gallery ?
-
August 31st, 2005, 06:42 AM
#4
Re: Extend width of Drop-down list of Combo Box
I don't like MFC stuff here, anyway your code will only result in a brighter dropdown-listbox of the combobox. Which isn't very smooth. It's better to have a scrollbar and don't let the listbox bloat up too much.
-
August 31st, 2005, 06:52 AM
#5
Re: Extend width of Drop-down list of Combo Box
If its better to have a scrollbar or wide list, depends on users. I do not like scrolling too much when some listbox has items with common prefix and invisible last part. Anyway, OP asked for widening a listbox, so this is what I gave him.
And about MFC stuff: In this case MFC just wraps Win32 API call (SendMessage). Theres nothing MFC specific here. I just wanted to say that if someone is interested in how to do something with Win32API, then he / she just should peek into MFC sources. This is often very helpful.
But of course dropdown list should not be too wide. This would be very irritating.
Hob
B+!
'There is no cat' - A. Einstein
Use [code] [/code] tags!
Did YOU share your photo with us at CG Members photo gallery ?
-
August 31st, 2005, 06:57 AM
#6
Re: Extend width of Drop-down list of Combo Box
Originally Posted by Hobson
And about MFC stuff: In this case MFC just wraps Win32 API call (SendMessage). Theres nothing MFC specific here. I just wanted to say that if someone is interested in how to do something with Win32API, then he / she just should peek into MFC sources. This is often very helpful.
But the OP didn't asked how MFC does it. And posting inside MFC code can be very dangerous for people who haven't used MFC, OOP with WinAPI that much. It can be very irritating. So posting just a simple non-MFC code piece showing how to use this message might be more helpfull than all this inside MFC stuff. Or just providing the MSDN Platform SDK reference to the message/function; as I do.
Originally Posted by Hobson
But of course dropdown list should not be too wide. This would be very irritating.
Personal preference as you said. But imagine a user who just uses 800x600 as a screen resolution. A widend combobox listbox might eat his half screen.
-
August 31st, 2005, 07:03 AM
#7
Re: Extend width of Drop-down list of Combo Box
Agree to both of above.
I removed MFC (potentially misleading and irritating) part of my 1st post
Hob
B+!
'There is no cat' - A. Einstein
Use [code] [/code] tags!
Did YOU share your photo with us at CG Members photo gallery ?
-
August 31st, 2005, 01:08 PM
#8
Re: Extend width of Drop-down list of Combo Box
CB_SETHORIZONTALEXTENT works like a charm!! THANKS, GUYS!!
We don't use MFC at work, just good old Win32 API. But I'd like to look into MFC later.
-
August 31st, 2005, 01:09 PM
#9
Re: Extend width of Drop-down list of Combo Box
OOPS.. I mean CB_SETDROPPEDWIDTH
-
November 4th, 2021, 08:49 PM
#10
Re: Extend width of Drop-down list of Combo Box
-
November 5th, 2021, 03:52 AM
#11
Re: Extend width of Drop-down list of Combo Box
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|