全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2172
推到 Plurk!
推到 Facebook!

請問列印StringGrid的問題~~

答題得分者是:william
kelon
一般會員


發表:17
回覆:27
積分:18
註冊:2002-07-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-12-24 09:57:56 IP:211.20.xxx.xxx 未訂閱
請問 我用以下的方式列印StringGrid... TPrinter *Prt=Printer(); Printer()->BeginDoc(); Grid->PaintTo(Prt->Handle,20,20); Printer()->EndDoc(); 可是列印的內容很小 而且我的筆數有200筆以上 可是卻只印出了大概15筆 要怎樣讓StringGrid的內容全部印出 還有怎麼設定大小呢??? 我用PrintDialog可以設定嗎???
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-12-24 11:51:08 IP:210.3.xxx.xxx 未訂閱
Your method only print the Canvas of the grid, so it can only print what is being displayed. The resolution of the screen is pretty small (e.g. 96dpi) and the resolution of the printer is a lot more (e.g. 300dpi), so the output will be a little bit small is you do not scale it before print.    Maybe a simple solution is to use 3rd party component which supports printing, e.g. http://www.vclxx.org/DELPHI/D32FREE/TVPRINTGRID.ZIP
引言: 請問 我用以下的方式列印StringGrid... TPrinter *Prt=Printer(); Printer()->BeginDoc(); Grid->PaintTo(Prt->Handle,20,20); Printer()->EndDoc(); 可是列印的內容很小 而且我的筆數有200筆以上 可是卻只印出了大概15筆 要怎樣讓StringGrid的內容全部印出 還有怎麼設定大小呢??? 我用PrintDialog可以設定嗎???
kelon
一般會員


發表:17
回覆:27
積分:18
註冊:2002-07-22

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-12-25 07:36:06 IP:61.219.xxx.xxx 未訂閱
再請問使用TPrinter() 可以將列印出來的放大嗎???
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-12-25 10:29:10 IP:210.3.xxx.xxx 未訂閱
引言:再請問使用TPrinter() 可以將列印出來的放大嗎???
You need to stretch the image and draw it on the printer's canvas. Take a look at the CreateDIBitmap and StretchDIBits API. >>
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-12-25 12:39:46 IP:203.73.xxx.xxx 未訂閱
引言: 可以將列印出來的放大嗎???
kelon 你好: 請參考以下的做法 < class="code"> void __fastcall TForm1::Button3Click(TObject *Sender) { StringGrid1->Width=400; StringGrid1->Height=400; Graphics::TBitmap *bmpBuf=new Graphics::TBitmap; bmpBuf->Width=2000; bmpBuf->Height=2000; bmpBuf->Canvas->CopyMode=cmSrcCopy; bmpBuf->Canvas->CopyRect(Rect(0, 0, bmpBuf->Width, bmpBuf->Height), StringGrid1->Canvas, Rect(0, 0, StringGrid1->Width, StringGrid1->Height)); TMemoryStream *msBuf=new TMemoryStream; bmpBuf->SaveToStream(msBuf); msBuf->Position=0; DWORD dwBfh=msBuf->Size; LPBITMAPFILEHEADER lpBfh=(LPBITMAPFILEHEADER)new BYTE[dwBfh]; msBuf->Read(lpBfh, dwBfh); LPBITMAPINFO lpBi=(LPBITMAPINFO)(lpBfh 1); LPBYTE lpBits=(LPBYTE)lpBfh lpBfh->bfOffBits; char szPrinterName[256]="XXX Printer"; HDC hDC=CreateDC("WINSPOOL", szPrinterName, NULL, NULL); DOCINFO DocInfo; memset(&DocInfo, 0, sizeof(DOCINFO)); DocInfo.cbSize=sizeof(DOCINFO); DocInfo.lpszDocName=NULL; DocInfo.lpszOutput=(LPTSTR)NULL; DocInfo.lpszDatatype=(LPTSTR)NULL; DocInfo.fwType=0; StartDoc(hDC, &DocInfo); StartPage(hDC); int nDstWidth=lpBi->bmiHeader.biWidth; int nDstHeight=lpBi->bmiHeader.biHeight; int nXDst=0; int nYDst=0; int nSrcWidth=lpBi->bmiHeader.biWidth; int nSrcHeight=lpBi->bmiHeader.biHeight; int nXSrc=0; int nYSrc=0; StretchDIBits(hDC, nXDst, nYDst, nDstWidth, nDstHeight, nXSrc, nYSrc, nSrcWidth, nSrcHeight, lpBits, lpBi, DIB_RGB_COLORS, SRCCOPY); EndPage(hDC); EndDoc(hDC); DeleteDC(hDC); delete lpBfh; delete msBuf; delete bmpBuf; } 備註: 以上sample code只適用於Windows NT/2000/XP 如果想要在Windows 98/ME中也可以用 則CreateDC這個fuction中的第一個參數要改變 請自行參考M$DN或Platform SDK --
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
kelon
一般會員


發表:17
回覆:27
積分:18
註冊:2002-07-22

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-12-25 15:06:29 IP:211.20.xxx.xxx 未訂閱
感謝兩位 
系統時間:2024-04-20 0:06:15
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!