Colour combo box used in Windows desktop 
Author Message
 Colour combo box used in Windows desktop

I wish to create a colour combo box picker which can also display some
text. The combo box will show some standard colours and if the user
selectes the item 'Other' they get displayed the standard Windows
colour dialog box.

I know that if you make the combo box owner drawn then I can add the
colours. But how do I then add the text to say 'Other'.

Help appreciated.



Mon, 31 Jul 2000 03:00:00 GMT  
 Colour combo box used in Windows desktop

OK, here's how I'd do it...

I'd take my standard owner-draw combo box for colors, and add one more
entry, whose ItemData was 0xFF000000.  This is based on knowing that
RGB(r,g,b) does not create a 0xFF in the high/order byte.  Now, when
that item is displayed, I'd just skip displaying the color block.
Then I'd change the OnSelChangeColor method to check to see if the
itemdata of the new selection was 0xFF000000.  If so, I'd pop up the
standard color dialog box.  What you do after that is now up to you.
You might want to add the new custom color to the dialog box (in which
case, you may want to give the user the option of naming it!), or just
set it whereever the color was supposed to go, then discard it.  If I
added to the combo box, I'd make it the current selection.  Ideally,
you will either use the CBS_SORT style and perform some kind of
sorting based on the color (such that 0xFF000000 sorts last) or simply
insert the new color in the next-to-last position so "Other" remains
last.

(I've got an assortment of code samples for doing color selection
boxes on the CD-ROM that accompanies our book, "Win32 Programming" by
Brent E. Rector and Joseph M. Newcomer).
                                joe



Quote:
>I wish to create a colour combo box picker which can also display some
>text. The combo box will show some standard colours and if the user
>selectes the item 'Other' they get displayed the standard Windows
>colour dialog box.

>I know that if you make the combo box owner drawn then I can add the
>colours. But how do I then add the text to say 'Other'.

>Help appreciated.

Joseph M. Newcomer

http://www3.pgh.net/~newcomer


Wed, 02 Aug 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. how do i change the colour of the text in a combo box

2. Using 256 colour bitmaps in dialog box

3. Visual C++ Combo boxes & Windows 2000

4. Visual C++ Combo boxes & Windows 2000

5. Visual C++ Combo boxes & Windows 2000

6. Visual C++ Combo boxes & Windows 2000

7. Composite Control using Combo Box

8. COMBO Box problems using Visual C++ (16 bit)

9. Need example of owner-drawn combo box using VC 4.2

10. Using Combo or List Box inside the Datagrid

11. using combo box for showing a list

12. sample for winCE application using combo box

 

 
Powered by phpBB® Forum Software