|
Hi,
thanks for sharing your work!
I have a little question, is it possible to change font size of a popup menu what is shown by mouse rightclick?
Thanks in advance
bosfan
|
|
|
|
|
I noticed that the vertical line was at the wrong place after scrolling horizontal.
So I added this
x -= GetParent()->GetScrollPos(SB_HORZ);
...before drawing the line.
pDC->MoveTo(x, rc.top);
pDC->LineTo(x, rc.bottom);
|
|
|
|
|
Hi,
Can we customize the menu in such a way that user can select multiple columns at once.
At present if user need to change the visibility of the 3 columns he needs to right click and select the columns individually. can we customs the menu in such a way that he can select the column in one go.
Thanks and Regards
Sharath B
"The world's biggest power is the youth and beauty of a woman."
|
|
|
|
|
There is a windows shortcut for auto resizing list control columns based on it's contents which is "Ctrl + +".
This reveals the zero width column, maybe this can also be handled.
|
|
|
|
|
Hi!
I have ported the application to VC6. Anyone interested, send me an e-mail and I will send you the zip file.
Best regards,
Christian.
I am in love with VC++
|
|
|
|
|
Hi Christian,
Tried several times to email you but that doesn't seem to work ( ).
I'm heavily interested in the port to VC6, can you please send it.
Thanks in advance
Leon...
|
|
|
|
|
Hi Leon!
Sorry for responding so late but I was caught up in some major problems at work.
I will send you the version as soon as I can (I only have access to it at home and now I am in another town).
In maximum two days I believe I will send it to you.
Thanks.
Best wishes,
Christian.
|
|
|
|
|
Hi Christian,
So far I have not received anything from you. Is this correct?
Cheers
Leon...
|
|
|
|
|
Try running TestListCtrl.exe in the demo project with the columns arranged
Col 0, Col 1, Col 2, Col 3, Col 4, Col 5
(Don't change the order of the columns using drag/drop)
Now right click on the header, and remove the tick from Col 1.
Next, remove tick from Col 2
Next, remove tick from Col 3
Next, remove tick from Col 4
Now put the tick back in Col 4.
The columns are now arranged in the wrong order. Col 4 is to the right of Col 5, but it should be on the left.
|
|
|
|
|
Nice work... I appreciated...
But I have in my project another CListCtrlEx with other functions. I would like to insert this functionalities that you created in my project, but I had problems... The first problems was with the "DWORD_PTR" and "CAutoPtr"
My project is a MFC application, in VC6.
Could you help me???
|
|
|
|
|
I would like a solution for VC6 too.
|
|
|
|
|
I solve it, in my way...
I changed DWORD_PTR for DWORD*, and CAutoPtr for int*.
I don't know if it is the best way, but it worked very well..
Excuses for my English.
See you.
|
|
|
|
|
I use a list control in a bare view (so I'm not using a CListView). During the creation sequence I get an ASSERT in CListCtrlEx::PreSubclassWindow: the header control is not yet created, so it's hWnd is NULL.
I worked around this as follows:
- added a Create() method to the CListCtrlEx class (same signature as CListCtrl)
- in that, first call base class version
- next, moved the contents of PreSubclassWindow()
|
|
|
|
|
Chen Hao, Thanks for contributing this class. Exactly what I was looking for.
Small problem: when unhiding a column, its size is reset to the original, during creation.
I applied the following fix in CHeaderCtrlEx::SetVisible (lines with >> added by me:
else
{
>> // store current width
>> CItemData *pData = (CItemData *)GetItemData(index);
>> pData->m_nWidth = GetItemWidth(index);
// hide item
SetItemWidth(index, 0);
}
|
|
|
|
|
I have 5 splitter windows where one of the view is ListView. Can anybody guide me to implement this feature for listview
Thanks,
Jaisri
|
|
|
|
|
Thanks for your article -- exactly what I needed!
I found one problem, however, it was easy to fix:
Dragging the rightmost header divider (i.e. to the right of the rightmost column header) can cause hidden columns to be revealed. I fixed this in CHeaderCtrlEx::OnLButtonDown:
<br />
if (ht.flags == HHT_ONDIVIDER)<br />
{<br />
ReleaseCapture();<br />
m_nDraggingItem = FindVisibleItem(index);
}<br />
else if (ht.flags == HHT_ONDIVOPEN)<br />
{<br />
ReleaseCapture();<br />
m_nDraggingItem = FindVisibleItem(index);<br />
}<br />
Hence the if (ht.flags == HHT_ONDIVIDER) block is the same as the if (ht.flags == HHT_ONDIVOPEN) block, and this could instead be reduced to:
<br />
if (ht.flags == HHT_ONDIVIDER || ht.flags == HHT_ONDIVOPEN)<br />
{<br />
ReleaseCapture();<br />
m_nDraggingItem = FindVisibleItem(index);<br />
}<br />
- HF
|
|
|
|
|
You can hide column just by set its width to 0.
|
|
|
|
|
But then the user begin drag divider he expand and view the zero-width column.
|
|
|
|
|
Did you fail to read the first paragraph?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Cool but memory leaks detected:
I think you have to change two class members:
first:
int CHeaderCtrlEx::IndexToOrder(int index)
{
int nOrder = -1;
int count = GetItemCount();
if (count > 0)
{
int* pnColOrder = new int[count];
GetOrderArray(pnColOrder, count);
for (int i = 0; i < count; i++)
{
if (pnColOrder[i] == index)
{
nOrder = i;
break;
}
}
// add the following
delete[] pnColOrder;
}
return nOrder;
}
and second
void CHeaderCtrlEx::SetVisible(int index, BOOL bVisible)
{
CItemData *pData = (CItemData *)GetItemData(index);
if (pData->m_bVisible != bVisible)
{
pData->m_bVisible = bVisible;
// get total items
int count = GetItemCount();
// get current item's order
int nOrder = IndexToOrder(index);
int* pCols= new int[count];
GetOrderArray(pCols, count);
if (bVisible)
{
// restore item width
ResetItemWidth(index);
// move the item to the original position
int nVisible = GetVisibleItemCount();
int nTarget;
if (index > nVisible - 1)
nTarget = nVisible - 1;
else
nTarget = index;
ASSERT(nTarget <= nOrder);
for (int i = nOrder; i > nTarget; i--)
pCols[i] = pCols[i - 1];
pCols[nTarget] = index;
}
else
{
// hide item
SetItemWidth(index, 0);
}
SetOrderArray(count, pCols);
// insert following:
delete[] pCols ;
}
}
|
|
|
|
|
...in "About Chen Hao" above, because it's the logotype of Sony Ericsson, and I doubt they want it used without their explicit permission, which you on the other hand might have received...?
--
The Blog: Bits and Pieces
|
|
|
|
|
>> I searched the Internet and did not find an existing solution for this
http://www.codeguru.com/Cpp/controls/listview/advanced/article.php/c4179
|
|
|
|
|
I also think that this article is interesting, but there is a thing I miss:
An article has to describe how things work, and not only how to use the code... 4 Points.
Don't try it, just do it!
|
|
|
|
|
I agree with you.
This article realy usefull.
|
|
|
|