 |
|
 |
The best (not the easiest) way I can think to do this is to take an existing implementation of a flat combo box (there are several out there), and simply "drop in" my item drawing code.
It should not be that hard to do...
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.6 Now!]
|
|
|
|
 |
|
 |
I need to use my custom colors, and a few methods would be useful for me, I think:
void RemoveAllColors();
btw, is control being updated?
|
|
|
|
 |
|
 |
I need to use my custom colors, and a few methods would be useful for me, I think: void RemoveAllColors();
You could just not call either of the stock Initialize... functions thus resulting in no colors needing to be removed and add your own. Although a new function to remove them all may be useful.
btw, is control being updated?
Yes, but only when I fix or add something.
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.6 Now!]
|
|
|
|
 |
|
 |
I want to create a comboBox in toolbar,But I don't know how to!
hope someone can help me!
Don't Look At Me That Way!
|
|
|
|
 |
|
 |
You need to create a Dialog bar, is easy.
best Regards And Happy Friday
Carlos Antollini.
|
|
|
|
 |
|
 |
Is it impossible to create a ComboBox in toolbar without creating a Dialog bar?
to be Ace.
|
|
|
|
 |
|
 |
You can create combobox in toolbar. I have one right now. But the easiest way is to use dialog bar.
|
|
|
|
 |
|
 |
Hi All!
I was wondering if it is possible to add a check box in front of each colour that is listed so that I could multiply select colours and use them as an input to my application
Thanks
indrajit
|
|
|
|
 |
|
 |
For this I would migrate my code into a CCheckListBox, or into a listview control that is created "in-place". Sounds like it would be too much work to do things like draw the checkboxes, handle clicks so that they do not dismiss the drop-down, etc.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
 |
|
 |
<BODY>
I found this class very useful. I happened to be using CMYK color tables (used in printing) at the time so I appended two functions which deal with the transformation of CMYK to RGB color values. Hope they're of some use.
</BODY>
//the Cyan, Magenta,Yellow and Black values need to be in a range of 0 to 1
int CColorPickerCB::AddColor( LPCTSTR cpColor, double Cyan, double Magenta, double Yellow, double Black )
{
COLORREF crColor = CMYKtoRGB(Cyan,Magenta,Yellow,Black);
return AddColor(cpColor,crColor);
}
COLORREF CColorPickerCB::CMYKtoRGB(double Cyan,double Magenta,double Yellow,double Black)
{
int Red, Green, Blue;
Red=(int)((1-__min(1,Cyan*(1-Black)+Black))*255);
Green=(int)((1-__min(1,Magenta*(1-Black)+Black))*255);
Blue=(int)((1-__min(1,Yellow*(1-Black)+Black))*255);
Green=Green<<8;
Blue=Blue<<16;
return Red | Green | Blue;
}
</HTML>
|
|
|
|
 |
|
 |
The code can be simplified by using the already defined CMYK or RGB macros defined in wingdi.h
/****************** BEFORE *****************/
COLORREF CColorPickerCB::CMYKtoRGB(double Cyan,double Magenta,double Yellow,double Black)
{
int Red, Green, Blue;
Red=(int)((1-__min(1,Cyan*(1-Black)+Black))*255);
Green=(int)((1-__min(1,Magenta*(1-Black)+Black))*255);
Blue=(int)((1-__min(1,Yellow*(1-Black)+Black))*255);
Green=Green<<8;
Blue=Blue<<16;
return Red | Green | Blue;
}
/****************** AFTER *****************/
COLORREF CColorPickerCB::CMYKtoRGB(double Cyan,double Magenta,double Yellow,double Black)
{
return CMYK(Cyan,Magenta,Yellow,Black);
/*
return RGB(
(int)((1-__min(1,Cyan*(1-Black)+Black))*255),
(int)((1-__min(1,Magenta*(1-Black)+Black))*255),
(int)((1-__min(1,Yellow*(1-Black)+Black))*255));
*/
}
Just my 2 cents.
-Erik
|
|
|
|
 |
|
|
 |
|
 |
I have recently submitted a current version of the control, with an updated article. Should be here soon...
-=- James
|
|
|
|
 |
|
 |
(I know it is bad form to follow-up to yer own post, but...)
The corrected version is here.
-=- James
|
|
|
|
 |
|
 |
When Mark Jackson "updated" the code, he removed some of the functions. To quote him: "I removed the functions I didn't need". Problem is, he removed the functions that he did not need, but others did need(!).
All of my comments also vanished from the files, so developers that are new to MFC are not going to learn anything from it now.
I believe that Mark's intent was to create a NEW Color Picker-type of control, as his comments in the file read: "based on the control by James R. Twine." That makes it sound like a new control, not additions/changes to an existing one.
Note that in my opinion, his changes reduce the functionality of the class. Also, the control had the AddColor(...) and RemoveColor(...) functions for a reason: The control was to be used to present a certain set of colors to the user. If I wanted the user to be able to select/define their own colors, I would use the standard Color Picker dialog. Adding the "Custom..." option in the selection defeats that purpose.
I will most likely update the code again, and return the functions that are supposed to be there. I may include Mark's DDX routines, because it can be useful. Besides, I have changed the color-set to something that is much richer.
I am also going to ask CP if Mark's version of the control can be a separate article.
Mark, this is nothing personal, BTW...
-=- James.
|
|
|
|
 |
|
 |
I'm new to MFC and Visual C++, I know how to make the dialog, and the combo box, I don't
know what to do next! How do I attach the CColorPickerCB to the control
|
|
|
|
 |
|
 |
If the code in correctly in your project, and the CLW file has been rebuilt, you will be able to directly attach it to a control using Classwizard. If the CLW file has not been rebuilt, attach a regular CComboBox, and just change the variable from a CComboBox to a CColorPickerCB.
-=- James
|
|
|
|
 |
|
 |
The following functions are NOT included in your class!
CString GetSelectedColorName(void); // Get Selected Color Name
void SetSelectedColorValue(COLORREF crColor) // Set Selected Color Value
void SetSelectedColorName(PCSTR cpColor); // Set Selected Color Name
bool RemoveColor(PCSTR cpColor); // Remove Color From List
bool RemoveColor(COLORREF crColor); // Remove Color From List
why?
where can I download the classfile with this functions?
roge
|
|
|
|
 |
|
 |
Good but where is the Get Functions??
|
|
|
|
 |
|
 |
Good point! I removed the functions I didn't need, the way I use it is with the DDX to automatically put the selected colour into a COLORREF member variable of the dialog class.
Mark.
|
|
|
|
 |