Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to decrease size of combo box ?

102 views
Skip to first unread message

Peter

unread,
Aug 20, 2008, 5:30:01 AM8/20/08
to
I have CListCtrl placed on dialog.
For editing subitems I have used CComboBox of type dropdown and this
CComboBox is placed on edited cell in time of editing.

Problem is that height of CComboBox rectangle which is created in resource
editor is more than my CListCtrl item height.
How to decrease height of CComboBox ?
(Not height of items in ComboBox drop down list but height of CComboBox
which is not active)

Peter

Tom Serface

unread,
Aug 20, 2008, 10:08:26 AM8/20/08
to
I'm not sure exactly what you are asking, but if you are resizing the
control when you overlay it on the list control you could use MoveWindow()
and get the size of the cell to determine the size of the control that is
supposed to fit there or you could just create it in the right place and the
right size as in the article below. Since users can resize columns (if you
let them that is) you would want to resize your control appropriately when
that happens.

If you are just trying to resize the control in the resource editor you can
click on the outside box of the control to resize horizontally, or click on
the down arrow to resize the drop down list size.

This article is a little dated so the sample code may not compile without
some conversion, but the steps listed here are good and I think this may be
what you're trying to do. In any event, it should help you get started.

http://www.codeguru.com/cpp/controls/listview/editingitemsandsubitem/article.php/c979

Tom

"Peter" <Pe...@discussions.microsoft.com> wrote in message
news:A462822E-160A-419D...@microsoft.com...

Ajay Kalra

unread,
Aug 20, 2008, 2:58:55 PM8/20/08
to

You should be able to change it by calling SetWindowPos on the
combobox.

-
Ajay

Unknown

unread,
Aug 20, 2008, 10:43:56 PM8/20/08
to
Peter wrote (in news:A462822E-160A-419D...@microsoft.com):

> I have CListCtrl placed on dialog.
> For editing subitems I have used CComboBox of type dropdown and this

> CComboBox is placed on edited cell in time of editing…


Use the combobox’s SetItemHeight function, passing -1 as the index:

m_ComboBox.SetItemHeight(-1, 23); //will make the control taller than usual
m_ComboBox.SetItemHeight(-1, 7); //will make the control shorter than usual

Just set the height to whatever the height of the items in your list control is.


HTH

--
Alec S.
news/alec->synetech/cjb/net


> …

Joseph M. Newcomer

unread,
Aug 21, 2008, 2:16:35 AM8/21/08
to
I presume that the "correct height" is obtained by GetWindowRect on the edit control, and
will not be a hardwired integer.
joe

On Wed, 20 Aug 2008 22:43:56 -0400, "Alec S." <@> wrote:

>Peter wrote (in news:A462822E-160A-419D...@microsoft.com):
>
>> I have CListCtrl placed on dialog.
>> For editing subitems I have used CComboBox of type dropdown and this
>> CComboBox is placed on edited cell in time of editing…
>
>
>Use the combobox’s SetItemHeight function, passing -1 as the index:
>
>m_ComboBox.SetItemHeight(-1, 23); //will make the control taller than usual
>m_ComboBox.SetItemHeight(-1, 7); //will make the control shorter than usual
>
>Just set the height to whatever the height of the items in your list control is.
>
>
>HTH

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Unknown

unread,
Aug 21, 2008, 12:31:19 PM8/21/08
to
Joseph M. Newcomer wrote (in news:612qa4d9ju6ad6plf...@4ax.com):

> I presume that the "correct height" is obtained by GetWindowRect on the edit
> control, and will not be a hardwired integer.

Oh haha! :P Only in pseudo code as a placeholder. I don’t like splaying open all
the viscera of my code when asking for help; I distill it down to the
essentials.


--
Alec S.
news/alec->synetech/cjb/net

> On Wed, 20 Aug 2008 22:43:56 -0400, "Alec S." <@> wrote:

Joseph M. Newcomer

unread,
Aug 21, 2008, 3:08:47 PM8/21/08
to
The problem is that in answering questions to people who can't make the leap from your
condensed code to the actual code they need to write, you end up letting them think that
the "7' is not just a placeholder, but an indication that they should put an integer in
that place. I actually had a student complain about one of my examples
if(!finder.IsDirectory())
... file stuff here
else
... directory stuff here

that there was an error in my example because the "..." wouldn't compile. Never
underestimate the lack of imagination of your readers...
joe


On Thu, 21 Aug 2008 12:31:19 -0400, "Alec S." <@> wrote:

>Joseph M. Newcomer wrote (in news:612qa4d9ju6ad6plf...@4ax.com):
>
>> I presume that the "correct height" is obtained by GetWindowRect on the edit
>> control, and will not be a hardwired integer.
>
>Oh haha! :P Only in pseudo code as a placeholder. I don’t like splaying open all
>the viscera of my code when asking for help; I distill it down to the
>essentials.

Unknown

unread,
Aug 21, 2008, 3:36:20 PM8/21/08
to
Joseph M. Newcomer wrote (in news:f5fra4h8kpmdbge2g...@4ax.com):

> I actually had a student complain about one of my examples
> if(!finder.IsDirectory())
> ... file stuff here
> else
> ... directory stuff here
> that there was an error in my example because the "..." wouldn't compile.
> Never underestimate the lack of imagination of your readers...


Fair enough. However I believe that my example was clear enough to remove
confusion for all but the most dense—whom I would imagine would have difficulty
programming anyway.


--
Alec S.
news/alec->synetech/cjb/net

> On Thu, 21 Aug 2008 12:31:19 -0400, "Alec S." <@> wrote:


>
> > Joseph M. Newcomer wrote (in
> > news:612qa4d9ju6ad6plf...@4ax.com):
> >
> > > I presume that the "correct height" is obtained by GetWindowRect on the
> > > edit control, and will not be a hardwired integer.
> >
> > Oh haha! :P Only in pseudo code as a placeholder. I don’t like splaying
> > open all the viscera of my code when asking for help; I distill it down to
> > the essentials.
>

0 new messages