|
I hosted this control inside a resizing dlg among other windows in a dlg based app..which had custom background painting.
I noticed that each time I re-sized the main dlg wnd..the scroll-bars got dirty until I passed the mouse over the scrollbar. This happens only on right-sizing, not down, and when the control's width becomes bigger than header's width. I traced the code to
CReportCtrl::ScrollWindow(INT iBar, INT iPos)
I have added this:
INT x = GetScrollPos32(SB_HORZ);
INT cx = m_iVirtualWidth;if(si.nMax){
VERIFY(m_wndHeader.SetWindowPos(&wndTop, -x, m_rectHeader.top, cx, m_rectHeader.Height(), m_dwStyle&RVS_NOHEADER ? SWP_HIDEWINDOW:SWP_SHOWWINDOW));
}
else{
VERIFY(m_wndHeader.SetWindowPos(&wndTop, -x, m_rectHeader.top, cx, m_rectHeader.Height(), m_dwStyle&RVS_NOHEADER ? SWP_HIDEWINDOW:SWP_SHOWWINDOW|SWP_NOREDRAW));
};
this also could help. the header's background not painting when the header doesn't occupy the whole client width, on resizing report control.
OnPaint comment
modified 9-Jun-13 4:20am.
|
|
|
|
|
another problem:
if the control it's made "re-sizable"..using some custom dialog class which handle its child controls...if the list it's scrolled at the end and the window gets enlarged at the bottom (enlarging also the report ctrl, the space at the bottom of the control it's filled with white space. the VScrollbar doesn't get updated until first click on it.
to update the V scrollbar I did:
void CReportCtrl::OnSize(UINT nType, int cx, int cy)
{
if(m_hEditWnd != NULL)
EndEdit();
CWnd::OnSize(nType, cx, cy);
CRect rect;
GetClientRect(rect);
Layout(rect.Width(), rect.Height());
INT iFirst = GetScrollPos32(SB_VERT), iLast;
INT iItems = GetVisibleRows(TRUE, &iFirst, &iLast);
SetScrollPos32(SB_VERT, GetScrollPos32(SB_VERT, TRUE));
iFirst = GetScrollPos32(SB_VERT);
GetVisibleRows(TRUE, &iFirst, &iLast);
GetVisibleRows(TRUE, &iFirst, &iLast, TRUE);
ScrollWindow(SB_VERT, iFirst);
}
|
|
|
|
|
BOOL CReportCtrl::SetItemTextColor(INT iItem, INT iSubItem, COLORREF crColor)
{
BOOL bFound = 0;
int i = 0;
int iColors = m_arrayColors.GetSize();
for (i=0;i<iColors;i++){
if(m_arrayColors[i]==crColor){
bFound=1;
break;
}
}
RVITEM rvi;
rvi.iItem = iItem;
rvi.iSubItem = iSubItem;
rvi.nMask = RVIM_TEXTCOLOR;
if(bFound){
rvi.iTextColor = i;
}
else{
rvi.iTextColor =InsertColor(iColors, crColor);
}
return SetItem(&rvi);
}
BOOL CReportCtrl::SetLineTextColor(INT iItem, COLORREF crColor)
{
int iCol = m_arrayColumns.GetSize(),i;
for (i=0;i<iCol;i++){
if(!SetItemTextColor(iItem, i, crColor))
return FALSE;
}
return TRUE;
}
CGSoftLabs.
modified 27-Mar-12 22:10pm.
|
|
|
|
|
After having fixed some errors due to changes to the compiler I compiled and run the demo, but it doesn't work as in VS2003: fields on the 2nd lines are left blank and resize of columns behaves strangely. I debugged a bit and it seems like WM_NOTIFY messages are not trapped. Has anyone a clue to fix this behavior?
thanks a lot.
|
|
|
|
|
I have noticed the same resizing problem and reached the same conclusion about notify messages but I haven't yet found a solution. Have you found anything?
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
Don't think this is the most elegant solution but it worked for me.
For some (obscure) reasons the message pump for ON_NOTIFY in not working anymore. I removed all the ON_NOTIFY from the Message Map and added this:
BOOL CReportCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
switch (((LPNMHDR)lParam)->code)
{
case RVN_ENDITEMEDIT:
OnRvnEndItemEdit((NMHDR *)lParam, pResult);
return *pResult;
case HDN_ITEMCHANGED:
OnHdnItemChanged((NMHDR *)lParam, pResult);
return *pResult;
case HDN_ITEMCLICK:
OnHdnItemClick((NMHDR *)lParam, pResult);
return *pResult;
case HDN_BEGINDRAG:
OnHdnBeginDrag((NMHDR *)lParam, pResult);
return *pResult;
case HDN_ENDDRAG:
OnHdnEndDrag((NMHDR *)lParam, pResult);
return *pResult;
case HDN_DIVIDERDBLCLICK:
OnHdnDividerDblClick((NMHDR *)lParam, pResult);
return *pResult;
default:
;
}
return CWnd::OnNotify(wParam, lParam, pResult);
}
everything seems to work as before.
|
|
|
|
|
Thanks.
I actually started to do something like that but then I decided to ditch all the code in favour of a simpler report control that just met all my needs. I'll remember your solution in case I ever need the more complete report control again.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
I fixed the NOTIFY problem by replacing in reportdemoview.cpp the ON_NOTIFY definitions with ON_NOTIFY_REFLECT, for example replace:
ON_NOTIFY(RVN_ITEMDRAWPREVIEW, 0, OnRvnItemDrawPreview)
with
ON_NOTIFY_REFLECT(RVN_ITEMDRAWPREVIEW, OnRvnItemDrawPreview)
|
|
|
|
|
How to fix this problem:
in ReportCtrl.h, replace
#define ID_HEADERCTRL 0
with e.g.
#define ID_HEADERCTRL 1243
in ReportCtrl.cpp, replace:
ON_NOTIFY(HDN_ITEMCHANGED, 0, OnHdnItemChanged)
ON_NOTIFY(HDN_ITEMCLICK, 0, OnHdnItemClick)
ON_NOTIFY(HDN_BEGINDRAG, 0, OnHdnBeginDrag)
ON_NOTIFY(HDN_ENDDRAG, 0, OnHdnEndDrag)
ON_NOTIFY(HDN_DIVIDERDBLCLICK, 0, OnHdnDividerDblClick)
ON_NOTIFY(RVN_ENDITEMEDIT, 0, OnRvnEndItemEdit)
with
ON_NOTIFY(HDN_ITEMCHANGED, ID_HEADERCTRL, OnHdnItemChanged)
ON_NOTIFY(HDN_ITEMCLICK, ID_HEADERCTRL, OnHdnItemClick)
ON_NOTIFY(HDN_BEGINDRAG, ID_HEADERCTRL, OnHdnBeginDrag)
ON_NOTIFY(HDN_ENDDRAG, ID_HEADERCTRL, OnHdnEndDrag)
ON_NOTIFY(HDN_DIVIDERDBLCLICK, ID_HEADERCTRL, OnHdnDividerDblClick)
ON_NOTIFY(RVN_ENDITEMEDIT, ID_HEADERCTRL, OnRvnEndItemEdit)
|
|
|
|
|
I've found that when the grid has focus, but all items are disabled (not sure what else is required to reproduce), you will get an index out of bounds exception if you press SPACE. To fix this, modify CReportCtrl::OnKeyDown like this (new row is bold):
...
if(!Notify(&nmrv))
{
switch (nChar)
{
case VK_SPACE:
if(m_iFocusRow != RVI_INVALID)
SelectRows(m_iFocusRow, m_iFocusRow, TRUE, TRUE, IsCtrlDown() ? TRUE:FALSE);
return;
...
|
|
|
|
|
Hello, thanks for this control.
I've been playing with the demo and have a question. How can I create a subitem that is a tree? All of the examples I've seen of this control create the tree in the first column, but I'd like to have a tree start in the 2nd column.
Is that possible?
I've tried the following in the tree view example in dialogs.cpp
m_rcTest.InsertItem("Test Root",-1,-1,-1,RVTI_ROOT,((HTREEITEM)(ULONG_PTR)-65534),1);
which should create Test Root in the subitem, as long as there's data in the first column, but this doesn't appear to work. It appears that InsertItem eventually assumes a subitem of 0.
Any ideas on how to implement this?
|
|
|
|
|
I want to use it to write a program ,but my data is so much.so i need virtual list to display the data.
it support virtual list?
thanks.
|
|
|
|
|
ATGrid报表控件简介
下载地址:
http://www.etcell.com/
http://www.etcell.com/download.aspx?id=51
ATGrid报表控件是在ETCell报表控件基础上推出的第二代报表控件,是一款完全对象化的报表组件。
ATGrid在功能上相对ETCell做出了重大改善:
支持多个ETSet数据集
支持7个子对象,最小对象到单元格
支持33种单元格数据类型
支持任意复杂格式报表数据展现
支持23种图表展示
扩展xml支持,操作数据更加灵活方便
改进打印功能,更好的支持套打、连续打印、分页打印
提供了ASP、ASP.NET、JSP、HP专用类库组件,提高开发效率
立即试用ATGrid报表控件
示例演示&源码下载
ATGrid报表控件功能
1、设计报表式样,生成模板文件
专用报表模板设计器,可视化设计报表式样
ATGrid报表控件有专门的设计器——wintable报表设计器,用来设计报表模板。wintable采用所见即所得的设计模式,类Excel操作界面风格,易学易用。可以直接导入Excel电子表格文件,也可以把ATGrid报表导出成Excel文件、html文件、xml文件。
支持分组、交叉、分栏等复杂报表
ATGrid报表控件采用表格方式构建报表,方便灵活,数据模型先进,可支持多个变长数据集,支持横纵向扩展,支持分组、交叉、分栏等复杂报表。
支持23种图表展现方式
ATGrid报表控件支持饼图、折线图、柱状图等23种图表展现方式,在一张报表中既可以有报表又可以有图表,大大丰富了报表数据的展现方式,增加了报表的可读性。
支持按钮、下拉列表、日期、多行文本等多种控件效果,支持会计表头、表览等多种特殊效果
ATGrid报表控件提供了33种单元格数据类型,包括数字、文本、密码、按钮、日期、列表等等,还包括会计表头、表览等多种特殊类型。使用ATGrid可以展现复杂的报表式样。
2、数据操作
拥有规范的xml数据格式
ATGrid报表控件提供xml数据接口,支持符合ATGrid数据格式规范的xml数据。ATGrid报表控件数据xml格式兼容ETcell报表控件数据格式。
内置通讯接口,强力支持HTTP协议,可以和后台程序轻松交互
ATGrid报表控件提供内置通讯接口,可以以post或get方式发送表单内数据或xml数据,可以接收返回的数据。为报表数据与其他程序交互操作提供了良好的支持,实现了数据与式样的分离。
采用Alias别名技术,可单独对单元格数据进行操作
ATGrid报表控件可以通过别名对单元格数据进行操作,大大增加了程序的灵活性和可扩展性。
数据模型先进,支持两种数据集——AliasSet和ETSet
ATGrid报表控件支持两种数据集模型,一种是AliasSet,相当于一条记录;一种是ETSet,相当于多条记录集。在ATGrid报表控件中可以直接对数据集进行操作,提高了编程的方便性。
ATGrid报表控件支持公式
ATGrid报表控件支持和Excel兼容的公式,单元格间可以自动进行计算。
3、编程接口控制
支持多种开发语言
支持多种常见开发语言,如JSP、ASP、ASP.NET、C#、HP、VB、VC++、Delphi、C++Builder、owerBuilder、Java等。
支持VBScript、JavaScript脚本
使用JavaScript或VBScript进行web编程,可以轻松实现浏览器端人机交互效果。
对象化编程
ATGrid是一款完全面向对象的报表控件,符合面向对象编程思想,支持7个子对象,最小对象到单元格,大大方便了面向对象编程。
提供数百个开发接口
ATGrid提供数百个开发接口,可以灵活的对式样、数据、事件进行控制。
4、打印输出
打印设置
可以按照打印效果的需要进行灵活的设置,包括页边距、纸张大小、打印方向、打印预览界面自定义、打印比例大小、表格线是否打印、是否自适应纸张、是否打印报表背景颜色、是否打印单元格背景,是否分页打印。
报表套打
可以按照预定格式,设置报表表格线是否打印、单元格是否打印,满足套打需要。
分页打印
可以设置固定表头等多种特殊效果,当数据过多超出一页纸时,可以进行分页打印。
自适应纸张打印
可以让报表自动缩放到符合纸张大小,充满整张纸,自动适应纸张进行打印。
导出其它格式文件
ATGrid报表可以导出Excel、html、xml等多种文件格式。导出为Excel文件时,报表内的公式、数据、式样会自动随着导出。
下载地址:
http://www.etcell.com/
http://www.etcell.com/download.aspx?id=51
|
|
|
|
|
HTREEITEM hRoot=m_rcTest.GetNextItem(RVTI_ROOT,RVGN_ROOT);//get the root item
if (hRoot!=NULL)
{
m_rcTest.Expand(hRoot,RVE_EXPAND);
}
|
|
|
|
|
How Can I Set the Last double clicked item's backcolor?
I aid the define:
#define RVIS_DBSELECTED 0x0200
when double click the item,i set the item has a style with RVIS_DBSELECTED;and in the DrawRow function ,i change the last double click item's backcolor.
if (lprvi->nState&RVIS_DBSELECTED)<br />
{<br />
crItem=m_crDBBkSelected;
}
But when i expand the tree node,the preview double clicked item remain have the m_crDBBkSelected backcolor
|
|
|
|
|
If using this control on a system with multiple displays, you will find problems adding items from the field chooser if the window is on a monitor with negative coordinates (i.e. to the left or above the primary display).
This is due to how it sends the coordinates to the header control allowing for the drawing of the red placement arrows, dropping the column in, etc.
m_iDropIndex = m_pReportCtrl->m_wndHeader.SendMessage(HDM_SETHOTDIVIDER, TRUE, MAKELONG(pt.x,pt.y));
MAKELONG returns a long obviously. However the params being passed to the macro are both longs. MAKELONG needs shorts to work properly. If not fixed, the headercontrol will receive the message and not get correct values for negative coordinates when doing HIWORD and LOWORD.
Make the following changes in CReportSubItemListCtrl::Dragging(CPoint pt)
/* cast the values to shorts */
short x = (short)pt.x;
short y = (short)pt.y;
m_iDropIndex = pReportCtrl->m_wndHeader.SendMessage(HDM_SETHOTDIVIDER, TRUE, MAKELONG(x,y));
In CFlatHeaderCtrl::OnSetHotDivider(WPARAM wParam, LPARAM lParam)
do:
short x = (short)LOWORD(lParam);
short y = (short)HIWORD(lParam);
hdhti.pt.x = x;
hdhti.pt.y = y;
This should fix your problem. I was seeing values in the -200s being converted to +60,000s in this handler until I made the changes.
TMB
|
|
|
|
|
This code is in ReportCtrl.cpp, line 5108 (aproximatelly) :
CPen pen(PS_SOLID, 2, RGB(0xFF, 0, 0));
CPen* pPen = pDC->SelectObject(&pen);
if(bDisable == TRUE)
{
rect.DeflateRect(1, 1);
if( lprvi->iCheck >= 4 )
rect.OffsetRect(2, 0);
pDC->MoveTo(rect.left, rect.top);
pDC->LineTo(rect.right-1, rect.bottom-1);
pDC->MoveTo(rect.right-1, rect.top);
pDC->LineTo(rect.left, rect.bottom-1);
pDC->SelectObject(pPen);
}
This is error, because if conditional block is not processed,
the pen is not restored. Result is when you use checkbox,
grid lines in next function are drawed in not right color.
Change it to:
CPen pen(PS_SOLID, 2, RGB(0xFF, 0, 0));
CPen* pPen = pDC->SelectObject(&pen);
if(bDisable == TRUE)
{
rect.DeflateRect(1, 1);
if( lprvi->iCheck >= 4 )
rect.OffsetRect(2, 0);
pDC->MoveTo(rect.left, rect.top);
pDC->LineTo(rect.right-1, rect.bottom-1);
pDC->MoveTo(rect.right-1, rect.top);
pDC->LineTo(rect.left, rect.bottom-1);
}
pDC->SelectObject(pPen);
|
|
|
|
|
I'd like to use CReportView instead of CListView which creates VS2003 in MDI app wizard with chosen "windows explorer" window style. Some problem is here with redrawing CReportCtrl content. I simple paste content of ReportCrtlDemo OnInitialUpdate() into the same member in MDI app's view class. After code executes this, in wiew nothing displays, till I click on non-visible header. Then control header stay visible, when I try drag - it's possible, but background does not redraws, there is only redrawing field like it is dragged. Probably is needed to add some message handler for redrawing report control ? What to do with it ?
|
|
|
|
|
Problem with redrawing backgroung is solved,
but still here is some problem with activating control.
After content is drawed I must to call rc.PostMessage(WM_ACTIVATE, 2, 0) and rc.PostMessage(WM_ACTIVATETOPLEVEL, 2, 0).
Both I investigate with spy++ with demo application.
What I dod wrong ? IMHO it should not need to send these messages.
|
|
|
|
|
Hi,
I've added the Unicode macros to my app, and I started to get errors with this function, such that I cannot solve myself:
OnToolTipNotify(UINT nId, NMHDR *pNMHDR, LRESULT *pResult)
I tried replacing the code in the function to this, but it started crashing whenever I hovered over the list header.
<br />
void ConvertStringToWChar (LPCTSTR str, WCHAR *buffer)<br />
{<br />
for (int i=0; str[i]; i++)<br />
buffer[i] = (WCHAR)str[i];<br />
buffer[i] = 0;<br />
}<br />
<br />
BOOL CFlatHeaderCtrl::OnToolTipNotify(UINT nId, NMHDR *pNMHDR, LRESULT *pResult)<br />
{<br />
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;<br />
<br />
if(<br />
pNMHDR->idFrom == (UINT)FLATHEADER_TT_MAGIC &&<br />
!m_arrayHdrItemEx[m_iHotIndex].strToolTip.IsEmpty()<br />
) {<br />
WCHAR *lpszW = new WCHAR[MAX_PATH];<br />
ConvertStringToWChar (m_arrayHdrItemEx[m_iHotIndex].strToolTip, lpszW);<br />
wcscpy((WCHAR*)pTTT->lpszText, lpszW);<br />
delete[] lpszW;<br />
<br />
pTTT->lpszText = pTTT->szText;<br />
return TRUE;<br />
}<br />
else <br />
return FALSE;<br />
}<br />
Crash is in this line:
VERIFY(pToolTip->SendMessage(TTM_ADDTOOL, 0, (LPARAM)&ti)); (tooltip.cpp ln 427).
Please help!
Stilgar.
|
|
|
|
|
I have exactly the same problem, but have not found how to fix it.
pToolTip->SendMessage(TTM_ADDTOOL, 0, (LPARAM)&ti) returns FALSE, but this happens only if compiled in UNICODE mode (which I would like to use). In ASCII mode it works fine and TTN_NEEDTEXT message is sent back to the grid control like it should. In UNICODE build the TTN_NEEDTEXT message never come.
I hope somebody have solved this,
Tim
|
|
|
|
|
I found sollution!
The TOOLINFO struct have changed from VC6 to VC7.1 by addition of one extra field (void* lpReserved), which is not used. For some reason (bug) VC7.1 can not handle the new TOOLINFO.
But UNICODE tooltips worked for me at least with this work-around, by decreasing the size member of TOOLINFO struct to the old VC6 size:
pToolInfo->cbSize = sizeof(TOOLINFO) - sizeof(void*);
Big thanks goes to this link (Place where I found the answer for the problem):
http://www.codecomments.com/archive372-2005-4-464854.html
|
|
|
|
|
Is there an outlook like control that also supports "group by" functionality?
|
|
|
|
|
|
There are some problems if I compile the demo with VC7.
1. ReportCtrl.cpp(322) : error C2065: 'm_pchData' is unkown
Why is it unkown. Where is it.
2.BOOL CFlatHeaderCtrl::GetItemEx
HDITEMEX& hditemex = m_arrayHdrItemEx[iPos];
The compiler don't like the &. Without it run's.
And the main problem... I can't see the text and the icons.
With the VC6 it run's very good. With icons and text.
Can you help me?
Thanks Bjoern
|
|
|
|
|