15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


custom color combobox.

Ramaswamy Hari -- hari@nextwave.com
Thursday, January 11, 1996

Hi,
	I want to create a custom color combobox in one of my dialog boxes. What I
want it to do is when I dropdown the list it should contain color rectangles 
instead of text. I looked at the MFC sample ctrltest which has a custom listbox
with colors. I tried AddString by converting an RGB() to a string as is done
in CTRLTEST but even after I add 8 items to the list, when I try the dropdown
arrow there is nothing in the list.

Here is what I have done.

 When I created the dialog I created a droplist combobox with ownerdrawn
(variable) type. I also created a new class called CMyColorComboBox derived 
from CComboBox and implemented the drawItem,MeasureItem & compare item routines.I changed the variable type for m_colorBox which represents the combobox to 
CMyColorComboBox in my dialog box header file. In my OnInitDialog function for
the dialog box I do the m_colorBox.AddString() calls by converting an RGB() to
a string.

I am using MSVC2.2.

Thanks in advance for any help in solving the problem. I would appreciate any
sample code which you could share.

thanks,

-hari




David W. Gillett -- DGILLETT@expertedge.com
Friday, January 12, 1996

> 	I want to create a custom color combobox in one of my dialog boxes. What I
> want it to do is when I dropdown the list it should contain color rectangles 
> instead of text. I looked at the MFC sample ctrltest which has a custom listbox
> with colors. I tried AddString by converting an RGB() to a string as is done
> in CTRLTEST but even after I add 8 items to the list, when I try the dropdown
> arrow there is nothing in the list.

  Do you see an empty list drop down?  Or does the list not appear at 
all???

  [The latter can happen if you haven't sized the control rectangle 
to make room for the dropped list, in AppStudio....  It's easy to 
miss.]

Dave

 




| Вернуться в корень Архива |