| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1839 人关注过本帖
标题:请教版主,你是如何用命令或程序设打印行距的。如半行。
只看楼主 加入收藏
jxwjlx
Rank: 1
等 级:新手上路
帖 子:236
专家分:8
注 册:2013-1-25
结帖率:97.78%
收藏
已结贴  问题点数:10 回复次数:21 
请教版主,你是如何用命令或程序设打印行距的。如半行。
。以前我是用文本框来做的。
搜索更多相关主题的帖子: 如何 文本框 
2014-01-07 13:40
GYYgyy124
Rank: 2
等 级:论坛游民
帖 子:9
专家分:10
注 册:2013-10-24
收藏
得分:5 
这是一个打印代码,楼主自己研究吧!
#DEFINE DIALOG_CLASS "_outputdialog"
#DEFINE DIALOG_CLASSLIB "_reports.vcx"

LOCAL lcRepName,loOutputDialog,lcDClass

DO CASE
CASE EMPTY(ALIAS())
    lcRepName = ""
CASE CURSORGETPROP("sourcetype")=3    && tables
    lcRepName = FORCEEXT(DBF(),"FRX")
OTHERWISE
    lcRepName = LEFT(ALIAS(),8)+".FRX"
ENDCASE

DO CASE
CASE FILE(DIALOG_CLASSLIB)
    lcDClass = DIALOG_CLASSLIB
CASE FILE(HOME()+"FFC\"+DIALOG_CLASSLIB)
    lcDClass = HOME()+"FFC\"+DIALOG_CLASSLIB
CASE FILE("..\FFC\"+DIALOG_CLASSLIB)
    lcDClass = "..\FFC\"+DIALOG_CLASSLIB
OTHERWISE
    THIS.Parent.PrintRpt()
    RETURN
ENDCASE

loOutputDialog = NewObject(DIALOG_CLASS,lcDClass)
IF VARTYPE(loOutputDialog) # "O" OR;
    (THIS.Parent.lNoRptSource AND !FILE(lcRepName))
    THIS.Parent.PrintRpt()
    RETURN
ENDIF

WITH loOutputDialog
    .cReport= IIF(FILE(lcRepName),lcRepName,"")
    .lPreventSourceChanges=THIS.Parent.lNoRptSource
    .lPreventScopeChanges=THIS.Parent.lNoRptScope
ENDWITH
loOutputDialog.Show(1)
2014-01-07 14:19
jxwjlx
Rank: 1
等 级:新手上路
帖 子:236
专家分:8
注 册:2013-1-25
收藏
得分:0 
能为我们新手加点注释就完美了。自己研究真如星火计划。
2014-01-07 14:23
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:2 
也没看懂
2014-01-07 14:28
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:0 
以下是引用jxwjlx在2014-1-7 13:40:59的发言:

。以前我是用文本框来做的。
在报表中设好就行
2014-01-07 14:29
jxwjlx
Rank: 1
等 级:新手上路
帖 子:236
专家分:8
注 册:2013-1-25
收藏
得分:0 
目前好像没有更好的办法。因为我打印的是一个edit中的文字。不是表。听说有的人用图像达到的,不知是否?
2014-01-07 14:37
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:0 
不是表 用什么打印?
2014-01-07 15:15
jxwjlx
Rank: 1
等 级:新手上路
帖 子:236
专家分:8
注 册:2013-1-25
收藏
得分:0 
editbox的内容。
2014-01-07 15:24
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:0 
没明白 不管什么内容 要用报表或是excel打印 还有别的打印方式?
2014-01-07 15:51
GYYgyy124
Rank: 2
等 级:论坛游民
帖 子:9
专家分:10
注 册:2013-10-24
收藏
得分:0 
以下是引用GYYgyy124在2014-1-7 14:19:45的发言:

这是一个打印代码,楼主自己研究吧!
#DEFINE DIALOG_CLASS "_outputdialog"
#DEFINE DIALOG_CLASSLIB "_reports.vcx"

LOCAL lcRepName,loOutputDialog,lcDClass

DO CASE
CASE EMPTY(ALIAS())
    lcRepName = ""
CASE CURSORGETPROP("sourcetype")=3    && tables
    lcRepName = FORCEEXT(DBF(),"FRX")
OTHERWISE
    lcRepName = LEFT(ALIAS(),8)+".FRX"
ENDCASE

DO CASE
CASE FILE(DIALOG_CLASSLIB)
    lcDClass = DIALOG_CLASSLIB
CASE FILE(HOME()+"FFC\"+DIALOG_CLASSLIB)
    lcDClass = HOME()+"FFC\"+DIALOG_CLASSLIB
CASE FILE("..\FFC\"+DIALOG_CLASSLIB)
    lcDClass = "..\FFC\"+DIALOG_CLASSLIB
OTHERWISE
    THIS.Parent.PrintRpt()
    RETURN
ENDCASE

loOutputDialog = NewObject(DIALOG_CLASS,lcDClass)
IF VARTYPE(loOutputDialog) # "O" OR;
    (THIS.Parent.lNoRptSource AND !FILE(lcRepName))
    THIS.Parent.PrintRpt()
    RETURN
ENDIF

WITH loOutputDialog
    .cReport= IIF(FILE(lcRepName),lcRepName,"")
    .lPreventSourceChanges=THIS.Parent.lNoRptSource
    .lPreventScopeChanges=THIS.Parent.lNoRptScope
ENDWITH
loOutputDialog.Show(1)
VFP中将表单的内容直接打印
*******************************************
*-- 程序名称:将表单的内容直接打印      --*
*-- 将窗口中的内容以一个位图的形式打印  --*
*-- 程序作者:未知,来源论坛转帖        --*
*-- 使用方法:在表单中执行该程序既可    --*
*           例:在某表单的一个command   --*
*           按纽中执行 do PrintForm.prg --*
*******************************************

*-- 定义常量
#DEFINE LOGPIXELSX           88
#DEFINE LOGPIXELSY           90
#DEFINE PHYSICALOFFSETX     112
#DEFINE PHYSICALOFFSETY     113
#DEFINE SRCCOPY        13369376
#DEFINE DIB_RGB_COLORS        0

*-- 调用本程序段中的子过程
DO decl

*-- 定义变量
PRIVATE pnWidth, pnHeight, lnBitsPerPixel, lnBytesPerScan
STORE 0 TO pnWidth, pnHeight, lnBitsPerPixel, lnBytesPerScan
LOCAL hwnd, hFormDC, hPrnDC, hMemDC, hMemBmp, hSavedBitmap,;
    xOffsPrn, yOffsPrn, xScale, yScale, lcDocInfo, lcBInfo, lpBitsArray

*-- 得到打印机设备的坐标偏移量
hPrnDC = getDefaultPrnDC()  && 没有进行错误检查
xOffsPrn = GetDeviceCaps(hPrnDC, PHYSICALOFFSETX)
yOffsPrn = GetDeviceCaps(hPrnDC, PHYSICALOFFSETY)

*-- 得到屏幕的窗口句柄,及她们的宽度、高度等。
hwnd = GetFocus()  && a window with keyboard focus
hFormDC = GetWindowDC(hwnd)
= getWinRect (hwnd, @pnWidth, @pnHeight)

*-- 根据屏幕和打印机得到缩放值
xScale = GetDeviceCaps(hPrnDC, LOGPIXELSX)/GetDeviceCaps(hFormDC,LOGPIXELSX)
yScale = GetDeviceCaps(hPrnDC, LOGPIXELSY)/GetDeviceCaps(hFormDC,LOGPIXELSY)

*-- 将屏幕的内容创建为位图图象数据
hMemDC = CreateCompatibleDC (hFormDC)
hMemBmp = CreateCompatibleBitmap (hFormDC, pnWidth, pnHeight)
hSavedBitmap = SelectObject(hMemDC, hMemBmp)

*-- 将位图数据从屏幕拷贝到虚拟设备上
= BitBlt (hMemDC, 0,0, pnWidth,pnHeight, hFormDC, 0,0, SRCCOPY)
= SelectObject(hMemDC, hSavedBitmap)

* retrieving bits from the compatible bitmap into a buffer
* as a device-independent bitmap (DIB) with a BitsPerPixel value
* as one of the printer device context
lcBInfo = InitBitmapInfo(hPrnDC)
lpBitsArray = InitBitsArray()
= GetDIBits (hMemDC, hMemBmp, 0, pnHeight,;
    lpBitsArray, @lcBInfo, DIB_RGB_COLORS)

lcDocInfo = Chr(20) + Repli(Chr(0), 19) && DOCINFO struct - 20 bytes
IF StartDoc(hPrnDC, @lcDocInfo) > 0
    = StartPage(hPrnDC)

    = StretchDIBits (hPrnDC, xOffsPrn, yOffsPrn,;
        xOffsPrn + Int(xScale * pnWidth),;
        yOffsPrn + Int(yScale * pnHeight),;
        0,0, pnWidth, pnHeight,;
        lpBitsArray, @lcBInfo, DIB_RGB_COLORS, SRCCOPY)

    = EndPage(hPrnDC)
    = EndDoc(hPrnDC)
ENDIF

*-- 退出时释放系统资源
= GlobalFree(lpBitsArray)
= DeleteObject(hMemBmp)
= DeleteDC(hMemDC)
= DeleteDC(hPrnDC)
= ReleaseDC(hwnd, hFormDC)
RETURN

PROCEDURE  getWinRect (lnHwnd, lnWidth, lnHeight)
    *-- 返回指定句柄的窗口的宽和高
    #DEFINE maxDword  4294967295  && 0xffffffff
    LOCAL lpRect, lnLeft, lnTop, lnRight, lnBottom
    lpRect = REPLI (Chr(0), 16)
    = GetWindowRect (lnHwnd, @lpRect)

    lnRight  = buf2dword(SUBSTR(lpRect,  9,4))
    lnBottom = buf2dword(SUBSTR(lpRect, 13,4))

    lnLeft   = buf2dword(SUBSTR(lpRect,  1,4))
    IF lnLeft > lnRight
        lnLeft = lnLeft - maxDword
    ENDIF
    lnTop    = buf2dword(SUBSTR(lpRect,  5,4))
    IF lnTop > lnBottom
        lnTop = lnTop - maxDword
    ENDIF

    lnWidth = lnRight - lnLeft
    lnHeight = lnBottom - lnTop
    RETURN

FUNCTION  getDefaultPrnDC
    * returns device context for the default printer
    #DEFINE PD_RETURNDC         256
    #DEFINE PD_RETURNDEFAULT   1024
    LOCAL lcStruct, lnFlags
    lnFlags = PD_RETURNDEFAULT + PD_RETURNDC

    * fill PRINTDLG structure
    lcStruct = num2dword(66) + Repli(Chr(0), 16) +;
        num2dword(lnFlags) + Repli(Chr(0), 42)
    IF PrintDlg (@lcStruct) <> 0
        RETURN buf2dword (SUBSTR(lcStruct, 17,4))
    ENDIF
    RETURN  0

FUNCTION  InitBitmapInfo(hTargetDC)
    #DEFINE BI_RGB         0
    #DEFINE RGBQUAD_SIZE   4  && RGBQUAD
    #DEFINE BHDR_SIZE     40  && BITMAPINFOHEADER

    LOCAL lnRgbQuadSize, lcRgbQuad, lcBIHdr

    * use printer BitPerPixel value
    lnBitsPerPixel = 24

    * initializing BitmapInfoHeader structure
    lcBIHdr = num2dword(BHDR_SIZE) +;
        num2dword(pnWidth) + num2dword(pnHeight) +;
        num2word(1) + num2word(lnBitsPerPixel) +;
        num2dword(BI_RGB) + Repli(Chr(0), 20)

    * creating a buffer for the color table
    IF lnBitsPerPixel <= 8
        lnRgbQuadSize = (2^lnBitsPerPixel) * RGBQUAD_SIZE
        lcRgbQuad = Repli(Chr(0), lnRgbQuadSize)
    ELSE
        lcRgbQuad = ""
    ENDIF
    RETURN  lcBIHdr + lcRgbQuad

PROCEDURE  InitBitsArray()
    #DEFINE GMEM_FIXED   0
    LOCAL lnPtr, lnAllocSize

    * making sure the value is DWORD-aligned
    lnBytesPerScan = Int((pnWidth * lnBitsPerPixel)/8)
    IF Mod(lnBytesPerScan, 4) <> 0
        lnBytesPerScan = lnBytesPerScan + 4 - Mod(lnBytesPerScan, 4)
    ENDIF

    lnAllocSize = pnHeight * lnBytesPerScan
    lnPtr = GlobalAlloc (GMEM_FIXED, lnAllocSize)
    = ZeroMemory (lnPtr, lnAllocSize)
    RETURN  lnPtr

FUNCTION  num2word (lnValue)
    RETURN Chr(MOD(m.lnValue,256)) + CHR(INT(m.lnValue/256))

FUNCTION  num2dword (lnValue)
    #DEFINE m0       256
    #DEFINE m1     65536
    #DEFINE m2  16777216
    LOCAL b0, b1, b2, b3
    b3 = Int(lnValue/m2)
    b2 = Int((lnValue - b3*m2)/m1)
    b1 = Int((lnValue - b3*m2 - b2*m1)/m0)
    b0 = Mod(lnValue, m0)
    RETURN Chr(b0)+Chr(b1)+Chr(b2)+Chr(b3)

FUNCTION  buf2word (lcBuffer)
    RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
        Asc(SUBSTR(lcBuffer, 2,1)) * 256

FUNCTION  buf2dword (lcBuffer)
    RETURN Asc(SUBSTR(lcBuffer, 1,1)) + ;
        Asc(SUBSTR(lcBuffer, 2,1)) * 256 +;
        Asc(SUBSTR(lcBuffer, 3,1)) * 65536 +;
        Asc(SUBSTR(lcBuffer, 4,1)) * 16777216

PROCEDURE  decl   && so many of them declared here
    DECLARE INTEGER GetFocus IN user32
    DECLARE INTEGER EndDoc IN gdi32 INTEGER hdc
    DECLARE INTEGER GetWindowDC IN user32 INTEGER hwnd
    DECLARE INTEGER DeleteObject IN gdi32 INTEGER hObject
    DECLARE INTEGER CreateCompatibleDC IN gdi32 INTEGER hdc
    DECLARE INTEGER ReleaseDC IN user32 INTEGER hwnd, INTEGER hdc
    DECLARE INTEGER GetWindowRect IN user32 INTEGER hwnd, STRING @lpRect
    DECLARE INTEGER GlobalAlloc IN kernel32 INTEGER wFlags, INTEGER dwBytes
    DECLARE INTEGER GetDeviceCaps IN gdi32 INTEGER hdc, INTEGER nIndex
    DECLARE INTEGER SelectObject IN gdi32 INTEGER hdc, INTEGER hObject
    DECLARE INTEGER StartDoc IN gdi32 INTEGER hdc, STRING @ lpdi
    DECLARE INTEGER GlobalFree IN kernel32 INTEGER hMem
    DECLARE INTEGER PrintDlg IN comdlg32 STRING @ lppd
    DECLARE INTEGER DeleteDC IN gdi32 INTEGER hdc
    DECLARE INTEGER StartPage IN gdi32 INTEGER hdc
    DECLARE INTEGER EndPage IN gdi32 INTEGER hdc

    DECLARE RtlZeroMemory IN kernel32 As ZeroMemory;
        INTEGER dest, INTEGER numBytes

    DECLARE INTEGER CreateCompatibleBitmap IN gdi32;
        INTEGER hdc, INTEGER nWidth, INTEGER nHeight

    DECLARE INTEGER BitBlt IN gdi32;
        INTEGER hDestDC, INTEGER x, INTEGER y,;
        INTEGER nWidth, INTEGER nHeight, INTEGER hSrcDC,;
        INTEGER xSrc, INTEGER ySrc, INTEGER dwRop

    DECLARE INTEGER StretchDIBits IN gdi32;
        INTEGER hdc, INTEGER XDest, INTEGER YDest,;
        INTEGER nDestWidth, INTEGER nDestHeight, INTEGER XSrc,;
        INTEGER YSrc, INTEGER nSrcWidth, INTEGER nSrcHeight,;
        INTEGER lpBits, STRING @lpBitsInfo,;
        INTEGER iUsage, INTEGER dwRop

    DECLARE INTEGER GetDIBits IN gdi32;
        INTEGER hdc, INTEGER hbmp, INTEGER uStartScan,;
        INTEGER cScanLines, INTEGER lpvBits, STRING @lpbi,;
        INTEGER uUsage
    RETURN      
 && decl
这个是将表单的内容以图片的形式打印。郑重申明:该代码非本人原创,是来自他人之手,希望可以帮到你!
2014-01-07 16:56
快速回复:请教版主,你是如何用命令或程序设打印行距的。如半行。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031833 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved