Guidance
指路人
g.yi.org
software / rapidq / Examples / Devices / Printer & Parallel Port / Print A Poster by PrinterDLL.bas

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
' PrinterDLL (PrinterDLL.dll) is a Dynamic Linked Library written by me,
' John White <yoingco@onetel.net.uk>, for myself and any programming
' language that can utilize it.

     $OPTIMIZE ON
     $APPTYPE GUI
     $TYPECHECK ON
     $ESCAPECHARS ON
     $INCLUDE "printerdll.inc"

     DIM form AS QFORM
     DIM B1 AS QBUTTON
     DIM rtn AS LONG, prt_Handle AS LONG, pdc_Handle AS LONG
     DIM bm1 AS QBITMAP

     DIM jobID AS LONG
     DIM stg$ AS STRING
     DIM counter AS LONG

     prt_Handle=0
     bm1.BMP="john.bmp"

     SUB BC1(Sender AS QBUTTON)
      jobID=Document_Open("Graphics and Text","","EMF")
      IF jobID>0 THEN

' Everything between Page_New and Page_Print is one page. If you want to draw/write on to
' another page (the next page) you must do another Page_New and Page_Print after this one.

       rtn=Page_New
       IF rtn=1 THEN

' Create a solid pen of 5 lines thick.
        Pen_CreateSolid(5,&H00000000)
' Draw a Border around the A4 page.
        Draw_Rectangle(50,50,2840,4050)
' Delete this current pen and restore the original pen.
        Pen_DeleteSolid

' The pen is back to 1 line thick.
' Draw a Frame for the Letter Header.
        Draw_Rectangle(500,140,2300,480)

' Set the current Font to Arial 16 x 36.
        stg$="Arial"
        Font_Create(36,16,1,1,FW_BOLD,ITALIC_OFF,UNDERLINE_OFF,STRIKEOUT_OFF,_
         DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,_
         DEFAULT_PITCH OR FF_DONTCARE,stg$)

' Set the Invitation Header.
        stg$="Wedding Invitation"
        Page_String(650,200,stg$,LEN(stg$))

' Delete this current Font and restore the original font.
        Font_Delete

' Set the current Font to Bookman Old Style 16 x 16.
        stg$="Bookman Old Style"
        Font_Create(16,16,1,1,FW_BOLD,ITALIC_OFF,UNDERLINE_ON,STRIKEOUT_OFF,_
         DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,_
         DEFAULT_PITCH OR FF_DONTCARE,stg$)

' Set the Invitation Titles.
        stg$="Guests"
        Page_String(80,800,stg$,LEN(stg$))

        stg$="In-Laws"
        Page_String(80,1200,stg$,LEN(stg$))

        stg$="Best Man"
        Page_String(80,1600,stg$,LEN(stg$))

        Font_Delete

' Set the current Font to Bookman Old Style 10 x 10.
        stg$="Bookman Old Style"
        Font_Create(10,10,1,1,FW_NORMAL,ITALIC_OFF,UNDERLINE_OFF,STRIKEOUT_OFF,_
         DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,_
         DEFAULT_PITCH OR FF_DONTCARE,stg$)

' Set the Invitation Title Descriptions.
        stg$="Guest are permitted to get Drunk, provided they be"
        Page_String(80,950,stg$,LEN(stg$))
        stg$="sick on the mother-in-law."
        Page_String(80,1050,stg$,LEN(stg$))

        stg$="In-Laws must tolerate any abuse hurled at them."
        Page_String(80,1350,stg$,LEN(stg$))

        stg$="Turn up on time and don`t forget the Rings."
        Page_String(80,1750,stg$,LEN(stg$))

' Print a Picture.
' Note. The size of my picture is 121 x 149 and so will come out
' small on a printer, simply because of the way printers handle DPI.
'
''Draw_Bitmap(bm1.Handle,0,0,80,1850,121,149,SRCCOPY)

' Now I will stretch the bitmap by 10 to represent a good/actual size.
        Draw_ResizedBitMap(bm1.Handle,0,0,121,149,80,1850,1210,1490,SRCCOPY)

        Font_Delete

        rtn=Page_Print
       END IF

' Put another Page_New and Page_Print here if you want to print another page.

       Document_Close
      END IF
     END SUB

     SUB CleanUp_PrinterDLL
      Printer_CloseDefault   ' CleanUp - Automatic error checking.
     END SUB

     SUB SetUp_PrinterDLL
' Initialize PrinterDLL, Open the Default Printer, Get PI2 and DevModes.

' 5000 - Internal Buffer Size (for the Clipboard, etc operations).
      rtn=Printer_OpenDefault(5000)
      IF rtn=4 THEN ' The Printer was opened, PI2 and DC were created.
' Get the Printer`s Handle.
       prt_Handle=Printer_GetHandle
       Form.SHOWMODAL
      ELSEIF rtn=3 THEN
       SHOWMESSAGE("Printer Opened and PI2 created - but no DC created")
       Printer_CloseDefault
      ELSEIF rtn=2 THEN
       SHOWMESSAGE("Printer Opened - but no PI2 or DC created")
       Printer_CloseDefault
      ELSEIF rtn=1 THEN
       SHOWMESSAGE("Printer - Failed to start Initialization")
      ELSE
       SHOWMESSAGE("Printer - Not Opened/Installed?")
' You could call Printer_AddPrinter() here.
      END IF
     END SUB

     Form.Width=180 : Form.Height=72 : Form.Center : Form.CAPTION=" Print A Poster"
     Form.OnClose=CleanUp_PrinterDLL

     B1.PARENT=Form : B1.CAPTION="Print" : B1.Top=6 : B1.Left=6
     B1.Width=140 : B1.Height=30 : B1.OnClick=BC1

' ------------------------- Initialize PrinterDLL -----------------------

     SetUp_PrinterDLL
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Thu 2021-10-21  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2004-01-10 20:19:09