|
when i dropdown any one combobox on the dialog ,it will appear one assertion like that "memery can't be read",
anyone meet the same situation?
|
|
|
|
|
The CMultiColumnComboBox::OnGetText returns 1 instead of the length of the string.
Instead of
return 1;
use
return _tcslen((LPTSTR)lParam);
|
|
|
|
|
if (m_HeaderControl != NULL)
error C2666: 'CWnd::operator !=' : 2 overloads have similar conversions
|
|
|
|
|
Its a great control, simple and easy to use.. but there are a couple of things wrong with the source files.
I had reason to use it recently, there is 1 thing to change if anyone else wants to use this: the DrawItem routine extracts a temporary DC using CDC::FromHandle(). This must be stored if it is to be used throughout the code.
Instead of:
CDC* DeviceContextPointer = CDC::FromHandle(lpDrawItemStruct->hDC);<br />
use
CDC DeviceContextPointer;<br />
DeviceContextPointer.Attach(lpDrawItemStruct->hDC);<br />
and call DeviceContextPointer.Detach() at the end of the routine.
Secondly, instead of
CWnd* DropDownWindowPointer = DeviceContextPointer.GetWindow();
use
lpDrawItemStruct->hwndItem
and use
if ((lpDrawItemStruct->itemState & ODS_COMBOBOXEDIT) != ODS_COMBOBOXEDIT)
to replace the (CWnd != this) check for editfield or drop rectangle.
Apart from a couple of niggles (eg, you can call AddRow() passing in fewer columns than configured which results in garbage being displayed, obviously) this control works fine. When implementing it, the BoundColumn is stored in the combobox itself and used as a 'key' to maintain the list.
Andy
|
|
|
|
|
Please, post the full code.
|
|
|
|
|
Nice control. Thanks for sharing.
I have one question.
To show more than 32736 items (beyond limit of MFC CComboBox), I need to show CListCtrl as Virtual List and to hide inbuilt-listbox of ComboBox.
Any idea how to do that ?
Thanks
Ana
|
|
|
|
|
|
How do we bind a combobox in ado to get a second recordset field 1 data as a dropdown data
|
|
|
|
|
I had a problem when using the control in a view where the list items did not draw until the mouse was passed over them. The fixes I made are:
ON_CONTROL_REFLECT(CBN_DROPDOWN, OnDropdown)
ON_MESSAGE(WM_USER + 105, OnSetFocusDrop)
CMultiColComboBox::CMultiColComboBox()
{
m_isOpen = false;
...
void CMultiColComboBox::OnDropdown()
{
m_isOpen = true;
}
void CMultiColComboBox::OnCloseup()
{
m_isOpen = false;
...
void CMultiColComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
...
CWnd* DropDownWindowPointer = DeviceContextPointer->GetWindow(); // original line
if ( DropDownWindowPointer == NULL ) // Resolution from CodeGuru comment from Boris Klyachko
{
if ( (GetWindowLong(m_hWnd, GWL_STYLE) & 0x3 ) == CBS_DROPDOWN )
{
traceObj.Info( "CBS_DROPDOWN" );
DropDownWindowPointer = GetWindow(GW_CHILD);
}
if ( (GetWindowLong(m_hWnd, GWL_STYLE) & 0x3 ) == CBS_DROPDOWNLIST )
{
traceObj.Info( "CBS_DROPDOWNLIST" );
DropDownWindowPointer = GetWindow( GW_HWNDFIRST );
if (DropDownWindowPointer == this && m_isOpen)
{ // should be the list
CWnd *DropDownWindowPointer2 = GetWindow(GW_HWNDLAST);
if (DropDownWindowPointer2)
DropDownWindowPointer = DropDownWindowPointer2;
}
}
}
...
void CMultiColComboBox::OnSetfocus()
{
if (bAutoDropDown && IsWindowVisible())
PostMessage(WM_USER + 105);
}
LRESULT CMultiColComboBox::OnSetFocusDrop(WPARAM wParam, LPARAM lParam)
{
if (!GetDroppedState())
ShowDropDown(TRUE);
return TRUE;
}
|
|
|
|
|
I do have problem with the Hotkey not working on the sorted combobox in XP.
The same identical codes works perfect on Win98 but not on XP.
Everything seems work fine except the hotkey in the combobox list.
The screen is not shifted to the first match key on the list in XP.
Anybody can help?
|
|
|
|
|
hi,
i tried the code. i have added m_CONTROL as a member variable for this of type CMultiColumnComboBox.just like AddRow, is there any function like DeleteRow? i am using DeleteString(int).12 rows have been added intially. now when i say
for(i=0;i<12;i++)
m_CONTROL.DeleteString(i);
all rows are not deleted but only 6of them.
can u solve this, please?
|
|
|
|
|
|
I like this MultiColumn ComboBox but, is it possible to have a " new " version of it, with all the corrections on it (m_HeaderControl.m_hWnd != NULL, windows2000, GetString(), SetString(),...) ?
Greeting : Viktor
|
|
|
|
|
http://codeguru.earthweb.com/mfc/comments/19587.shtml[^] contains instructions on how to get the appropriate window handle for use within the DrawItem() function.
John
"We want to be alone when we hear too many words and we feel alone when it has been a while since anyone has spoken to us." Paul David Tripp -- War of Words
|
|
|
|
|
|
After a few changes, I've used it successfully on 2000, XP, and NT machines.
John
"We want to be alone when we hear too many words and we feel alone when it has been a while since anyone has spoken to us." Paul David Tripp -- War of Words
|
|
|
|
|
I just debugged an annoying crash (an unhandled exception that only occurred once in a while) caused by the control under W2K. If you're having the same problem, go into the CMultiColumnComboBox::OnGetText function and replace the third argument of the 'memcpy' with the actual length of the text string, provided it is smaller than the length specified by wParam. Here's the snippet of modified code that fixed the crash for me:
if (ShowColumnItemIndex < BoundColumnItemCount)
{
CString text = m_ColumnItemList[m_BoundColumn].GetAt(m_ColumnItemList[m_BoundColumn].FindIndex(ShowColumnItemIndex));
memcpy((void *) (LPCTSTR) lParam, text, text.GetLength());
return 1;
}
else
return 0;
|
|
|
|
|
Platform: Win2k, SP 2, VC 6 + SP5.
Problem: Only 1 column in every ComboBox, even in author sample.
Solution: ??????????????
|
|
|
|
|
Hi and thanks very much to Xiao Wu Guang and all the people who wrote new things for these files.
I really like this MultiColumn ComboBox.
But, is it possible to have a " new " version of it, with all the corrections on it (m_HeaderControl.m_hWnd != NULL,windows2000,GetString(),SetString(),...) ?
One more thing, is it possible to have the code to have the EditBox with columns too, or how can I choose the column data I want in the EditBox ?
(Is it comprehensive ??? )
Thanks again to all of you nd especially to Xiao Wu Guang.
Cynicannibal
|
|
|
|
|
|
I try to execute MultiColumnComboBox demo by Xiao Wu Guang
and i have four errors like this:
error C2666: '!=' : 2 overloads have similar conversions
in code line :
if (m_HeaderControl != NULL)
Could you tell me what does this error mean?
Thank you.
|
|
|
|
|
Replace this: if (m_HeaderControl != NULL)
on
if (m_HeaderControl.m_hWnd != NULL)
|
|
|
|
|
This multicolumn control worked fine for Windows 98 and Windows ME; however, it produces totally unacceptable results for Windows XP. Several programmers have ask about these problems on both the Code Project and CodeGuru without any solutions from the author or anyone else. This control is an orphan and is not being supported. Unless you have lots of time to shoot XP or W2000 problems, I recommend you pass on this control.
|
|
|
|
|
Hi!!
It has added to my project.
Very Nice!!
My personal computer OS was changed into Windows2000 from Windows98.
Windows98 is satisfactory.
It cannot be used in Windows2000.
It does not work when a dropdown button is pushing.
I propose it.
A supplementary code is added to CMultiColumnComboBox.cpp.
void CMultiColumnComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
ASSERT(m_TotalColumn > 1);
CPen* OldPenPointer;
CDC* DeviceContextPointer = CDC::FromHandle(lpDrawItemStruct->hDC);
CWnd* DropDownWindowPointer = DeviceContextPointer->GetWindow();
BOOL IsHighLightText = lpDrawItemStruct->itemAction & ODA_FOCUS || lpDrawItemStruct->itemState & ODS_SELECTED;
CRect TextRectangle = lpDrawItemStruct->rcItem;
// **** Additional coding Start ****
if (DropDownWindowPointer == NULL)
{
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);
}
}
// **** Additional coding End ****
..............
Was it repaired this?
Can it be work on Windows2000 and Windows98?
:-DMy program does not have a problem.
By Hiromitsu Hotta
Thanks
Add Message:
When investigating the bulletin board well, Jason Good had shown previously.
I did not know.
It is the same idea.
Thanks Jason Good
|
|
|
|
|
good work.
but I have another problem , when draw down the box, the data can not be displayed correctly.
thanks,
|
|
|
|