社区
界面
帖子详情
vc中怎么打印整个控件的内容的?比如CListCtrl在report模式下
tohell
2005-04-12 07:31:57
如题
...全文
165
6
打赏
收藏
vc中怎么打印整个控件的内容的?比如CListCtrl在report模式下
如题
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
zhangnanonnet
2005-04-13
打赏
举报
回复
http://www.vckbase.com/code/findcode.asp?mclsid=&sclsid=&keyword=%B4%F2%D3%A1&page=3
ShiGang
2005-04-13
打赏
举报
回复
循壞讀取,然后寫入印表機DC中
cnwolf
2005-04-13
打赏
举报
回复
/*该结构用于存储各列的信息,打印函数使用*/
typedef struct tagColAtt
{
int nColIndex;
CString strColText;
int nPrintX;
int nSubItemIndex;
}
COLATT;
BOOL PrintListCtrl(CListCtrl &list)
{
PRINTDLG pd;
pd.lStructSize = sizeof(PRINTDLG);
pd.Flags = PD_RETURNDC;
pd.hDC = NULL;
pd.hwndOwner = NULL;
pd.hInstance = NULL;
pd.nMaxPage = 1;
pd.nMinPage = 1;
pd.nFromPage = 1;
pd.nToPage = 1;
pd.nCopies = 1;
pd.hDevMode = NULL;
pd.hDevNames = NULL;
AfxMessageBox("由于字段内容较多,请选择横向打印。");
//显示打印对话框,由用户来设定纸张大小等。
if(!PrintDlg(&pd)) return FALSE;
ASSERT(pd.hDC!=NULL);
int nHorRes = GetDeviceCaps(pd.hDC, HORZRES);
int nVerRes = GetDeviceCaps(pd.hDC, VERTRES);
int nXMargin = 2;
int nYMargin = 2;
TEXTMETRIC tm;
GetTextMetrics(pd.hDC, &tm);
int nCharHeight = tm.tmHeight;
int nCharWidth = tm.tmAveCharWidth;
CHeaderCtrl* pHeader = list.GetHeaderCtrl();
//获得行,列的个数
int nColCount = pHeader->GetItemCount();
int nLineCount = list.GetItemCount();
int ColOrderArray[20];
COLATT ca[20];
list.GetColumnOrderArray(ColOrderArray, nColCount);
int nColX =nXMargin*nCharWidth;
int nColXArray[20];
memset(nColXArray,0,20);
nColXArray[0] = nColX;
for (int i =1 ; i<= nColCount; i++)
nColXArray[i] = nColXArray[i-1] + list.GetColumnWidth(i-1);
//检索各列的信息,确定列标题的内容长度。
for(i =0 ; i< nColCount; i++)
{
ca[i].nColIndex = ColOrderArray[i];
LVCOLUMN lvc;
char text[20];
lvc.mask = LVCF_TEXT|LVCF_SUBITEM;
lvc.pszText = text;
lvc.cchTextMax = 20;
list.GetColumn(ca[i].nColIndex, &lvc);
ca[i].strColText = lvc.pszText;
ca[i].nSubItemIndex = lvc.iSubItem;
ca[i].nPrintX = nColXArray[i]*nHorRes/nColXArray[nColCount];
}
DOCINFO di;
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "打印审计信息查询结果";
di.lpszOutput = (LPTSTR) NULL;
di.lpszDatatype = (LPTSTR) NULL;
di.fwType = 0;
StartDoc(pd.hDC, &di);
StartPage(pd.hDC);
//输出列标题
for(i =0; i<nColCount; i++)
TextOut(pd.hDC, ca[i].nPrintX, nYMargin,
ca[i].strColText, strlen(ca[i].strColText));
int nMaxLinePerPage = nVerRes/nCharHeight -3;
int nCurPage =1;
//输出各列的数据
for(i =0; i<nLineCount; i++)
{
for(int j =0; j<nColCount; j++)
{
if(i+1-(nCurPage-1)*nMaxLinePerPage > nMaxLinePerPage)
{
//新的一页
EndPage(pd.hDC);
StartPage(pd.hDC);
nCurPage ++;
}
CString subitem = list.GetItemText(i, j);
TextOut(pd.hDC, ca[j].nPrintX,nYMargin+(i+1-(nCurPage-1)*nMaxLinePerPage)*nCharHeight,subitem, strlen(subitem));
}
}
EndPage(pd.hDC);
EndDoc(pd.hDC);
//打印结束
DeleteDC(pd.hDC);
return TRUE;
}
wxdvc
2005-04-13
打赏
举报
回复
mark
vc
中
列表
控件
框的扩展(不是列表框)
实现了,微软自带的列表
控件
没实现的相关功能,比如实现
控件
的编辑。。。自己看吧,很简单的,直接将里面的
report
.h/.cpp文件引入到自己工程工程就ok,相当于自己写的类(继承于
CLi
stCtrl
)
颜色列表视图的使用 colorlist
在使用
CLi
stCtrl
控件
的过程
中
,我们会发现使用及其不方便,特别是在使用“
report
"显示
模式
时, 想给指定条目添加背景颜色,
CLi
stCtrl
控件
所提供的设置颜色函数只能使得
控件
的界面变得好看一些,根本不能满足我们的...
vc
++ 应用源码包_6
内含各种例子(
vc
下各种
控件
的使用方法、标题栏与菜单栏、工具栏与状态栏、图标与光标、程序窗口、程序控制、进程与线程、字符串、文件读写操作、文件与文件夹属性操作、文件与文件夹系统操作、系统控制操作、程序...
VC
中
Li
stCtrl
经验总结
Li
stCtrl
在工作
中
,常常用到,也常常看到大家发帖问怎么用这个
控件
,故总结了一下自己的使用经验,以供参考使用。 先注明一下,这里,我们用m_li
stctrl
来表示一个
CLi
stCtrl
的类对象,然后这里我们的Li
stCtrl
都是...
vc
++ 应用源码包_1
内含各种例子(
vc
下各种
控件
的使用方法、标题栏与菜单栏、工具栏与状态栏、图标与光标、程序窗口、程序控制、进程与线程、字符串、文件读写操作、文件与文件夹属性操作、文件与文件夹系统操作、系统控制操作、程序...
界面
15,979
社区成员
115,896
社区内容
发帖
与我相关
我的任务
界面
VC/MFC 界面
复制链接
扫一扫
分享
社区描述
VC/MFC 界面
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章