读书人

Rich Edit 2.0 Control怎么打印、插入

发布时间: 2012-12-15 15:16:03 作者: rapoo

Rich Edit 2.0 Control如何打印、插入表格、排版?
排版如左边图片,右边是文字,如:

图片: 参数:
数据1:128329
数据2:282592
数据3:829382
.....


可否有人做过?
[解决办法]
该回复于2012-05-03 19:36:52被版主删除
[解决办法]
怎么被删了,是在做广告吗!
进去看了,这控件价格确实不菲。
[解决办法]
该回复于2012-05-04 08:34:10被版主删除
[解决办法]
是告,但是很有用,不像一些版主,死了
[解决办法]
如果我知道是?他很的
[解决办法]
我删的,这是csdn规定,请你遵守。

[解决办法]

引用:
我删的,这是csdn规定,请你遵守。


OK,,,你好,,,,,看好了
[解决办法]
如何使用来自 Rich Edit(CRichEditCtrl) 控件的内置打印功能 .
http://support.microsoft.com/kb/129860

示例代码

void Print(HDC hPrinterDC, HWND hRTFWnd)
{
FORMATRANGE fr;
int nHorizRes = GetDeviceCaps(hPrinterDC, HORZRES),
nVertRes = GetDeviceCaps(hPrinterDC, VERTRES),
nLogPixelsX = GetDeviceCaps(hPrinterDC, LOGPIXELSX),
nLogPixelsY = GetDeviceCaps(hPrinterDC, LOGPIXELSY);
LONG lTextLength; // Length of document.
LONG lTextPrinted; // Amount of document printed.

// Ensure the printer DC is in MM_TEXT mode.
SetMapMode ( hPrinterDC, MM_TEXT );

// Rendering to the same DC we are measuring.
ZeroMemory(&fr, sizeof(fr));
fr.hdc = fr.hdcTarget = hPrinterDC;



// Set up the page.
fr.rcPage.left = fr.rcPage.top = 0;
fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440;
fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440;

// Set up 1" margins all around.
fr.rc.left = fr.rcPage.left + 1440; // 1440 TWIPS = 1 inch.
fr.rc.top = fr.rcPage.top + 1440;
fr.rc.right = fr.rcPage.right - 1440;
fr.rc.bottom = fr.rcPage.bottom - 1440;

// Default the range of text to print as the entire document.
fr.chrg.cpMin = 0;
fr.chrg.cpMax = -1;

// Set up the print job (standard printing stuff here).
ZeroMemory(&di, sizeof(di));
di.cbSize = sizeof(DOCINFO);
if (*szFileName)
di.lpszDocName = szFileName;
else
{
di.lpszDocName = "(Untitled)";

// Do not print to file.
di.lpszOutput = NULL;
}

// Start the document.
StartDoc(hPrinterDC, &di);

// Find out real size of document in characters.
lTextLength = SendMessage ( hRTFWnd, WM_GETTEXTLENGTH, 0, 0 );

do
{
// Start the page.
StartPage(hPrinterDC);

// Print as much text as can fit on a page. The return value is
// the index of the first character on the next page. Using TRUE
// for the wParam parameter causes the text to be printed.

#ifdef USE_BANDING

lTextPrinted = SendMessage(hRTFWnd,
EM_FORMATRANGE,
FALSE,


(LPARAM)&fr);
SendMessage(hRTFWnd, EM_DISPLAYBAND, 0, (LPARAM)&fr.rc);

#else

lTextPrinted = SendMessage(hRTFWnd,
EM_FORMATRANGE,
TRUE,
(LPARAM)&fr);

#endif

// Print last page.
EndPage(hPrinterDC);

// If there is more text to print, adjust the range of characters
// to start printing at the first character of the next page.
if (lTextPrinted < lTextLength)
{
fr.chrg.cpMin = lTextPrinted;
fr.chrg.cpMax = -1;
}
}
while (lTextPrinted < lTextLength);

// Tell the control to release cached information.
SendMessage(hRTFWnd, EM_FORMATRANGE, 0, (LPARAM)NULL);

EndDoc (hPrinterDC);
}

以上代码有错误
ZeroMemory(&di, sizeof(di));
di.cbSize = sizeof(DOCINFO);
if (*szFileName)
di.lpszDocName = szFileName;
else
{
di.lpszDocName = "(Untitled)";

// Do not print to file.
di.lpszOutput = NULL;
}

di在哪里定义,什么类型,还有print函数如何调用?
请高手指点
[解决办法]
哎,人你的,只是聊天地方
[解决办法]
typedef struct {
int cbSize;
LPCTSTR lpszDocName;


LPCTSTR lpszOutput;
LPCTSTR lpszDatatype;
DWORD fwType;
} DOCINFO, *LPDOCINFO;
di 是一个docinfo
调用的话
void Print(HDC hPrinterDC, HWND hRTFWnd) 第一个参数是打印机的DC ,后面那个是rtf的句柄
==================
以上是从代码推断,可能会有误差
[解决办法]
多谢,提示

读书人网 >VC

热点推荐