Board index » Visual Studio » How to determine the number of visible items in the drop down of a CComboBox

How to determine the number of visible items in the drop down of a CComboBox

Visual Studio351
Hello,



Is there an easy way to determine how many items are currently visible in

the dropdown list of a CComboBox.



(I dont need the total number from GetCount)



Thanks


-
 

Re:How to determine the number of visible items in the drop down of a CComboBox

Seems to me you could use GetDroppedControlRect() and GetItemHeight() to

figure it out.



Tom





"D Smith" <kingospam(no spam)@adelphia.net>wrote in message

Quote
Hello,



Is there an easy way to determine how many items are currently visible in

the dropdown list of a CComboBox.



(I dont need the total number from GetCount)



Thanks







-

Re:How to determine the number of visible items in the drop down of a CComboBox

Take a look at my dynamically-resizing combo box on my MVP Tips site. I set the size to

make it as unlikely as possible that a scrollbar would be needed. \



joe



On Thu, 22 Sep 2005 16:20:41 -0400, "D Smith" <kingospam(no spam)@adelphia.net>wrote:



Quote
Hello,



Is there an easy way to determine how many items are currently visible in

the dropdown list of a CComboBox.



(I dont need the total number from GetCount)



Thanks



Joseph M. Newcomer [MVP]

email: newcomer@flounder.com

Web: www.flounder.com">www.flounder.com

MVP Tips: www.flounder.com/mvp_tips.htm">www.flounder.com/mvp_tips.htm

-

Re:How to determine the number of visible items in the drop down of a CComboBox

In case anyone is interested, I think this is another case of inaccurate

MicroSoft documentation.



I had tried GetDroppedControlRect first and the numbers did not seem to work

out. Of course I was assuming that the rectangle returned was the rectangle

that gets dropped BELOW the edit box.



I looked at it again and it seems like the rectangle returned contains both

the dropped list and the editbox. I subtracted off the editbox item height

[GetItemHeight(-1)]and 8 more (for spacing around the editbox) and arrived

at a number that could be divided by GetItemHeight(0) to arrive at the

correct number of visible items.





-

Re:How to determine the number of visible items in the drop down of a CComboBox

Instead of 8, you might want to look at this in terms of ::GetSystemMetrics for border

sizes. It could change depending on your display resolution.

joe



On Fri, 23 Sep 2005 13:51:26 -0400, "D Smith" <kingospam(no spam)@adelphia.net>wrote:



Quote
In case anyone is interested, I think this is another case of inaccurate

MicroSoft documentation.



I had tried GetDroppedControlRect first and the numbers did not seem to work

out. Of course I was assuming that the rectangle returned was the rectangle

that gets dropped BELOW the edit box.



I looked at it again and it seems like the rectangle returned contains both

the dropped list and the editbox. I subtracted off the editbox item height

[GetItemHeight(-1)]and 8 more (for spacing around the editbox) and arrived

at a number that could be divided by GetItemHeight(0) to arrive at the

correct number of visible items.



Joseph M. Newcomer [MVP]

email: newcomer@flounder.com

Web: www.flounder.com">www.flounder.com

MVP Tips: www.flounder.com/mvp_tips.htm">www.flounder.com/mvp_tips.htm

-