|
Thanks!
I encountered the same problem.
William
|
|
|
|
|
I have the same exact errors.
Jimmy
|
|
|
|
|
I've been using this control for almost 3 years now and for 2 of those, it has worked perfectly without any problems. As everyone knows by now, this control (as it was originally written) does not work in Windows 2000 (and I would imagine WinXP also), generating what used to be known as a "Dr. Watson" error when the user clicked on the drop-down arrow. After trying a couple of suggested fixes, I settled on one which seemed to work the best. Here's the code I used to replace the method used to obtain a pointer to the drop-down window in the DrawItem function:
if ((GetWindowLong(m_hWnd, GWL_STYLE) & 0x3) == CBS_DROPDOWN)
DropDownWindowPointer = GetWindow(GW_CHILD);
if ((GetWindowLong(m_hWnd, GWL_STYLE) & 0x3) == CBS_DROPDOWNLIST)
DropDownWindowPointer = GetWindow(GW_HWNDFIRST);
This works great with one exception: If the right side of the drop-down exceeds the value of GetSystemMetrics(SM_CXSCREEN), the drop-down window is no longer moved to the left to prevent the right from going off of the screen. It seems that DropDownWindowPointer->GetWindowRect(WindowRectangle) returns a CRect which is relative to the dialog (property page, etc.) instead of being relative to the display. Therefore, when WindowRectangle.right is compared to GetSystemMetrics(SM_CXSCREEN), WindowRectangle.right is always less than GetSystemMetrics(SM_CXSCREEN) and therefore, the code which moves the window is never executed. Realizing this, I wrote some code which added the CRect.left values of the combo box and all its parents and then added this value to the WindowRectangle.right value. In my case, GetSystemMetrics(SM_CXSCREEN) returned 1152 and my total came out to be 1205. Using the original code from this point, the WindowRectangle was correctly offset by -13; however, to my surprise, the drop-down still did not move.
Does anyone out there have the same problem? If so, what did you do to fix it? Any help would be greatly appreciated.
Jason Good
|
|
|
|
|
Hi,
I have a version of your CMultiColumnComboBox ( I don´t know how old it is... ), and in Windows XP, when you drop down the list you have to pass the mouse over the items and then they are drawn ( if not it is shown empty).
Was this and old bug from that class ?, Thanks !
Braulio
|
|
|
|
|
Hello
Has anyone converted this class so it's compatible with PocketPC ?
|
|
|
|
|
This is purely esthetic, but the line of code that sets the text color uses COLOR_WINDOWTEXT when the control is disabled. I changed that to COLOR_GREYTEXT when the control is disabled and the control now displays the same as a normal combo when it is disabled.
The line of code is as follows
DeviceContextPointer->SetTextColor(GetSysColor(IsWindowEnabled() ? (IsHighLightText ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT) : COLOR_WINDOWTEXT));
and I have changed it to
DeviceContextPointer->SetTextColor(GetSysColor(IsWindowEnabled() ? (IsHighLightText ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT) : COLOR_GREYTEXT));
You can find this line in the DrawItem method of the class implementation file.
Chris Meech
|
|
|
|
|
when I use a UpdateData(FALSE)in a dialog through DDX_CBString,I can't see the string assigned at the edit of MultiColumnComboBox,It is NULL. Can anyone help me?
thanks in advance
ricky
|
|
|
|
|
I get this message after compiling on a Win 2000 machine and then trying to click on one of the drop downs. This error occurs immediately. Any ideas as to why?
Thanks
|
|
|
|
|
|
Even with the sample!
|
|
|
|
|
may i know how to incorporate a deletion function for the data in the comboboxs list
i tried to change the m_ColumnListItem. it reflected the list properly. but when i see the display it is not getting displayed properly. why?
Is there something to be done in the DrawItem function??
Thanks in advance
Regards
Jithu
Jithu
|
|
|
|
|
Check this out: http://www.exontrol.com/sg.jsp?content=products/excombobox
Mike
www.exontrol.com
|
|
|
|
|
Hi,
I think it´s not fear to add free advertisement inside a contribution.
The good combo that Xiao Wang gived to us is for free and with the source code. If you want to sell your things please spend your money on Marketing or whatever, if not some angry gurus at Codeproject, will begin to implement your controls for free with the source code... What do you think Chris or Nish or...
Bye !
Braulio
|
|
|
|
|
It's very good,but,I think it can change to flat?
please help me.
|
|
|
|
|
Used CMultiColumnComboBox in a dll and binded with dropdown-ownerdraw-variable-hasstring CCombobox, with DDX_CONTROL and a CString with DDX_CBString to handle the edit text, but it is critical to get the right content current in Edit box....updated some codes, then some comboboxes still can handle it correctly, but somes of them just got null strings.....lost the idea where I made the problem?
any help would be appreciate, how can I handle those edit content more sure and safety? will try to modify CMultiColumnComboBox slightly to get it, but, or, could it's caused because of some fault I never noticed with my application?
thanks in advance
Paul
|
|
|
|
|
I have a situation where I have setup a three column MCC such that there are multiple strings for column one that are the same, mulitple strings for column two are the same, and multiple strings for column three are the same. No matter what values I pass to FormatComboBox for the bound column and show column, after selecting an entry, when you next click for the drop down, it will be an incorrect entry that is high lighted in the drop down list. For an example consider a database table that has three columns titled Country, State, and City. The combination of all three will make a unique entry, but a list of all countries will certainly have duplicates, as will a listing of all states or cities. I tried to understand the code that high lights an item in the drop down list, but it was not clear how the list item id was determined. Whatever it is, I think the logic has difficulty dealing with duplicates in the bound column.
As an aside, I also discovered that if you pass a number for bound column to the FormatComboBox routine that is greater than the number of columns, in Debug mode you get an assertion failure of trying to subclass a window twice. I think somehow the CComboBoxEdit member trys to get subclass'ed twice.
Thanks.
Chris
|
|
|
|
|
Occasionally I have a problem whereby the column separators are askew i.e. the column widths of some rows are different than others! This only happens when running a release-built .exe. It doesn't happen when running from within Visual Studio. Can anyone help?
NH
|
|
|
|
|
I have downloaded the new version and tried adding Column header. Column header shows up nicely. Now if I select a particular item from the drop down list and pull up the drop down list again, scrolling to the selected item does not happen. Well, if I scroll down using mouse it shows the selection. However, this problem does not occur if I don't show the column header [i.e. if I don't use the function SetColumnTitle(...)]. Does anyone have any clue !
|
|
|
|
|
This control has been a great one for me. If you have upgraded to Win2K you can find a fix for this control at www.codeguru.com. I've modified this control to be able to edit the contents of a dropdown lists column in the edit box and have the dropdown list reflect the edit. In case anyone is interested.
Steve P.
|
|
|
|
|
By the way, a wonderful control -- thank you for providing it.
I am having a problem however, my combobox has 2 columns and 7 rows of data. I want the data from the first column to be displayed in the text box so I used 2,1,0 as the parameters for FormatComboBox(). This is what happens:
When I click on the last row it will not display in the text box.
After selecting either rows 5, 6, or 7 and then clicking on the text box's down arrow, the text in the text box instantly shows the data from the second row. I can still click on other rows and their data will display but a subsequent click on the text box's down arrow changes the text box contents immediately. That shouldn't happen until I select a row.
Any idea what's going on here or has anyone else seen this behavior? I have similar types of strange behavior for all combinations of arguments to FormatComboBox()
|
|
|
|
|
I would like to know how can I display multiple records on any dialog box.Can I use Listview control to bind to the table in the oracle database?
if not how to show on the front-end from the oracle database at the front-end.In VB what I asked is simple thing using DBGrid Controls or MSFlexGrid Controls.
Waiting for your suggetion
V.Subramanyam
|
|
|
|
|
|
Here is a little bug ( and also a fix ):
If you select the last ( or first ) visible item in the listbox and move the mouse down ( or up ), all the items that scrolled into the listbox are marked selected and have a focus-rectangle.
Here is a fix that worked for me:
void CMultiColumnComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
ASSERT(m_TotalColumn > 1); //You can use CComboBox class instead of this class
CPen* OldPenPointer;
CDC* DeviceContextPointer = CDC::FromHandle(lpDrawItemStruct->hDC);
CWnd* DropDownWindowPointer = DeviceContextPointer->GetWindow();
// BOOL IsHighLightText = lpDrawItemStruct->itemAction & ODA_FOCUS || lpDrawItemStruct->itemState & ODS_SELECTED;
// added te
bool bHasFocus = lpDrawItemStruct->itemState & ODS_FOCUS ? true : false;
bool bIsSelected = lpDrawItemStruct->itemState & ODS_SELECTED? true : false;
//
CRect TextRectangle = lpDrawItemStruct->rcItem;
DeviceContextPointer->SetTextColor(GetSysColor(IsWindowEnabled() ? (bIsSelected ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT) : COLOR_WINDOWTEXT));
DeviceContextPointer->SetBkColor(GetSysColor(IsWindowEnabled() ? (bIsSelected ? COLOR_HIGHLIGHT : COLOR_WINDOW) : COLOR_3DFACE));
DeviceContextPointer->FillRect(TextRectangle, &CBrush(DeviceContextPointer->GetBkColor()));
// changed te
if( true == bHasFocus /*IsHighLightText*/){
DeviceContextPointer->DrawFocusRect(TextRectangle);
}
if(lpDrawItemStruct->itemID != (UINT)-1)
{
if (DropDownWindowPointer != this) //Draw items in drop down list
{
if (TextRectangle.top == 0 && m_ComboBoxStyle != CBS_SIMPLE)
{ //Only "dropdwon" & "drop list" combo box can move their drop down window
CRect DropDownWindowRectangle;
DropDownWindowPointer->GetWindowRect(DropDownWindowRectangle);
if (DropDownWindowRectangle.right > GetSystemMetrics(SM_CXSCREEN)) //Move drop down window to left if its left side is out of screen
{
DropDownWindowRectangle.OffsetRect(GetSystemMetrics(SM_CXSCREEN) - DropDownWindowRectangle.right, 0);
DropDownWindowPointer->MoveWindow(DropDownWindowRectangle);
}
if (m_HeaderControl.GetSafeHwnd() != NULL)
{
CRect WindowRectangle;
GetWindowRect(WindowRectangle);
if (DropDownWindowRectangle.top - WindowRectangle.top < 39)
{
m_HeaderControl.SetWindowPos(&wndBottom, DropDownWindowRectangle.left, WindowRectangle.top + 21, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
DropDownWindowRectangle.top += 18;
/*Two lines added*/
if (DropDownWindowRectangle.bottom - DropDownWindowRectangle.top < 18){
DropDownWindowRectangle.bottom = DropDownWindowRectangle.top + 18;
}
DropDownWindowPointer->MoveWindow(DropDownWindowRectangle);
}
}
}
// changed te
if( false == bHasFocus /*!IsHighLightText*/)
{
OldPenPointer = DeviceContextPointer->SelectObject(&m_LightGrayPen);
DeviceContextPointer->MoveTo(TextRectangle.left, TextRectangle.bottom - 1);
DeviceContextPointer->LineTo(TextRectangle.right, TextRectangle.bottom - 1);
DeviceContextPointer->SelectObject(OldPenPointer);
}
// changed te
if( false == bIsSelected/*!IsHighLightText*/)
{
OldPenPointer = DeviceContextPointer->SelectObject(&m_LightGrayPen);
}
TextRectangle.left += LEFTMARGIN_OF_DROPDOWNLIST;
TextRectangle.right = TextRectangle.left;
for(INT ColumnIndex = 0; ColumnIndex < m_TotalColumn; ColumnIndex++)
{
TextRectangle.left = TextRectangle.right;
if (m_ColumnWidth[ColumnIndex] != 0)
{
if (ColumnIndex > 1 || (ColumnIndex == 1 && m_ColumnWidth[0] != 0))
{
TextRectangle.left += SPACE_BETWEEN_COLUMN;
// changed te
if (false == bIsSelected /*!IsHighLightText*/)
{ //draw vertical gray line
DeviceContextPointer->MoveTo(TextRectangle.left - SPACE_BETWEEN_COLUMN / 2, TextRectangle.top);
DeviceContextPointer->LineTo(TextRectangle.left - SPACE_BETWEEN_COLUMN / 2, TextRectangle.bottom);
}
}
TextRectangle.right = TextRectangle.left + m_ColumnWidth[ColumnIndex];
TextRectangle.left++;
// if vertical scrool bar is visible
// if ((ColumnIndex == m_TotalColumn - 1 || (ColumnIndex == m_TotalColumn - 2 && m_ColumnWidth[m_TotalColumn - 1] == 0)) && (DropDownWindowPointer->GetStyle() & WS_VSCROLL))
// TextRectangle.right -= GetSystemMetrics(SM_CXVSCROLL);
DeviceContextPointer->DrawText(m_ColumnItemList[ColumnIndex].GetAt(m_ColumnItemList[ColumnIndex].FindIndex(lpDrawItemStruct->itemID)), -1, TextRectangle,
m_ColumnAlignStyle[ColumnIndex] | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
}
}
// changed te
if( false == bIsSelected/*!IsHighLightText*/)
DeviceContextPointer->SelectObject(OldPenPointer);
}
else //Draw item in edit box control/static text control
{
TextRectangle.left += LEFTMARGIN_OF_CONTROL;
if( m_ColumnsInEditCtrl.GetSize() ){
CString strText;
POSITION Pos;
int nIndex;
for( int i = 0; i < m_ColumnsInEditCtrl.GetSize(); i++ ){
if( 0 != i ){
strText += " ";
}
nIndex = m_ColumnsInEditCtrl[i];
Pos = m_ColumnItemList[nIndex].FindIndex(lpDrawItemStruct->itemID);
strText += m_ColumnItemList[nIndex].GetAt(Pos);
}
DeviceContextPointer->DrawText(strText, -1, TextRectangle,DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
}
else if (m_ColumnWidth[m_BoundColumn] > 0)
DeviceContextPointer->DrawText(m_ColumnItemList[m_BoundColumn].GetAt(m_ColumnItemList[m_BoundColumn].FindIndex(lpDrawItemStruct->itemID)), -1, TextRectangle,
m_ColumnAlignStyle[m_BoundColumn] | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
else //Bound column is hidden
{
DeviceContextPointer->DrawText(m_ColumnItemList[m_ShowColumn].GetAt(m_ColumnItemList[m_ShowColumn].FindIndex(lpDrawItemStruct->itemID)), -1, TextRectangle,
m_ColumnAlignStyle[m_ShowColumn] | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER);
}
}
}
}
|
|
|
|
|
Try this: Add a title and then only add a single row. The row does not appear; instead, only the title will. The problem is that once a title is added, only n-1 rows will appear, always dropping the last one
|
|
|
|
|
Thank you for finding a error for me.
The dropdown window has to be resized for the title window. If its height is small than 18, the dropdown window cannot be seen. You can modify it like follow:
CRect WindowRectangle;
GetWindowRect(WindowRectangle);
if (DropDownWindowRectangle.top - WindowRectangle.top < 39)
{
m_HeaderControl.SetWindowPos(&wndBottom, DropDownWindowRectangle.left, WindowRectangle.top + 21, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
DropDownWindowRectangle.top += 18;
/*Two lines added*/
if (DropDownWindowRectangle.bottom - DropDownWindowRectangle.top < 18)
DropDownWindowRectangle.bottom = DropDownWindowRectangle.top + 18;
DropDownWindowPointer->MoveWindow(DropDownWindowRectangle);
}
|
|
|
|
|