Download demo project - 46 Kb
Download source files - 7 Kb

This control easily gives your application the Flat Look that is seen
in the Microsoft office products.
To use the control, simply add the files CCJFlatComboBox.cpp and CCJFlatComboBox.h to your project. You
can use Class Wizard to add the CCJFlatComboBox member variables ( you most likely will have to rebuild the
.clw file associated with your project ), or just replace any instance of CComboBox , with CCJFlatComboBox .
Example
Below is and example of how you might add the control to your project.
Header file:
enum { IDD = IDD_FLATCOMBODEMO_DIALOG };
CCJFlatComboBox m_DDCombo;
Implementation file:
DDX_Control(pDX, IDC_DROPDOWN_COMBO, m_DDCombo);
Acknowledgements:
- Chris Maunder - For letting me use his color picker class, and for his auto-completion code. I made some modifications to the appearance of the control that is used in this demo. My modifications are noted.
- Gilberto Botaro - For his help with adding auto completion to the CCJFlatComboBox class.
- Vachik Hovhannissian and Danilo Lax - For help with fixing focus and message handling bugs.
- Yosh Yamashita - For help with fixing accelerator bug.
- Shannon McCoy - For suggestions on using ::GetSysColor(...) and ::GetSystemMetrics(...) more efficiently.
- Todd Brannam - For help with fixing offset bug to use GetSystemMetrics().
| You must Sign In to use this message board. |
|
| | Msgs 1 to 4 of 4 (Total in Forum: 4) (Refresh) | FirstPrevNext |
|
 |
|
 |
First of all, thanks. This class helped me beautify an old application.
However, i ran into a problem with message reflection (not happening). I often use OnKillFocus in the a CComboBox's parent window (Dialog) to handle data updates and after swapping out my CCombos for CJFlatCombos, my parent window OnKillFocus handlers would never get called. To solve it, i used ON_CONTROL_REFLECT_EX instead of ON_CONTROL_REFLECT.
In the header file you need to change these: afx_msg void OnSetFocus(); afx_msg void OnKillFocus(); afx_msg void OnEditUpdate();
To these: afx_msg BOOL OnSetFocus(); afx_msg BOOL OnKillFocus(); afx_msg BOOL OnEditUpdate();
And in the cpp change: ON_CONTROL_REFLECT(CBN_SETFOCUS, OnSetFocus) ON_CONTROL_REFLECT(CBN_KILLFOCUS, OnKillFocus) ON_CONTROL_REFLECT(CBN_EDITUPDATE, OnEditUpdate)
To these: ON_CONTROL_REFLECT_EX(CBN_SETFOCUS, OnSetFocus) ON_CONTROL_REFLECT_EX(CBN_KILLFOCUS, OnKillFocus) ON_CONTROL_REFLECT_EX(CBN_EDITUPDATE, OnEditUpdate)
Then change the method implementations so that they all return a BOOL value of FALSE, like this:
BOOL CCJFlatComboBox::OnKillFocus() { m_bHasFocus = FALSE; DrawCombo( normal, m_clrBtnFace, m_clrBtnFace ); return FALSE; //let the parent take a shot at the message }
Now command routing can continue as necessary
Larry
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
Same thing here... I almost got it to work with a CComboBoxEx but not quite...
I can send what I got up to if that's of any interest to any one... the only problem is that the flat look seems to reappear sneakily!
The only way I have found is to post (PostMessage not SendMessage) a WM_PAINT message on the OnPaint of the parent dialog (not exactly nice portable code - is it?). And it is not working all the time - and obviously the repaint does happen right away depending on the load of the message loop!
Any idea anyone ? or any alternative to this great class otherwise - which deservedly got my 5?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Ever thought of upgrading this to a CComboBoxEx? I just tried by simply changing all CComboBox to CComboBoxEx instances. Surprisingly it didn't work 
|
| Sign In·View Thread·PermaLink | 4.67/5 (5 votes) |
|
|
|
 |
|
|
General
News
Question
Answer
Joke
Rant
Admin