home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 35 / hot35.iso / ficheros / LVB / T2W32543.ZIP / _PRINTER.FRM < prev    next >
Text File  |  1998-05-21  |  14KB  |  398 lines

  1. VERSION 5.00
  2. Begin VB.Form frmPrinter 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Printer"
  5.    ClientHeight    =   4845
  6.    ClientLeft      =   1890
  7.    ClientTop       =   3270
  8.    ClientWidth     =   7485
  9.    MaxButton       =   0   'False
  10.    MDIChild        =   -1  'True
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   4845
  13.    ScaleWidth      =   7485
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.Frame Frame1 
  16.       Height          =   570
  17.       Left            =   0
  18.       TabIndex        =   1
  19.       Top             =   -90
  20.       Width           =   7485
  21.       Begin VB.CommandButton cmdNP 
  22.          Caption         =   ">"
  23.          Height          =   285
  24.          Index           =   1
  25.          Left            =   7110
  26.          TabIndex        =   6
  27.          Top             =   195
  28.          Width           =   285
  29.       End
  30.       Begin VB.CommandButton cmdNP 
  31.          Caption         =   "<"
  32.          Height          =   285
  33.          Index           =   0
  34.          Left            =   6210
  35.          TabIndex        =   5
  36.          Top             =   195
  37.          Width           =   285
  38.       End
  39.       Begin VB.CommandButton Command1 
  40.          Caption         =   "&Go"
  41.          Default         =   -1  'True
  42.          Height          =   285
  43.          Left            =   6570
  44.          TabIndex        =   4
  45.          Top             =   195
  46.          Width           =   465
  47.       End
  48.       Begin VB.ComboBox cmb_Function 
  49.          Height          =   315
  50.          Left            =   1365
  51.          TabIndex        =   2
  52.          Top             =   180
  53.          Width           =   4755
  54.       End
  55.       Begin VB.Label Label2 
  56.          Caption         =   "&Select a function"
  57.          Height          =   255
  58.          Left            =   90
  59.          TabIndex        =   3
  60.          Top             =   210
  61.          Width           =   1275
  62.       End
  63.    End
  64.    Begin VB.TextBox txt_Result 
  65.       BackColor       =   &H00C0C0C0&
  66.       BorderStyle     =   0  'None
  67.       Height          =   4110
  68.       Left            =   105
  69.       Locked          =   -1  'True
  70.       MultiLine       =   -1  'True
  71.       ScrollBars      =   2  'Vertical
  72.       TabIndex        =   0
  73.       Top             =   630
  74.       Width           =   7260
  75.    End
  76. End
  77. Attribute VB_Name = "frmPrinter"
  78. Attribute VB_GlobalNameSpace = False
  79. Attribute VB_Creatable = False
  80. Attribute VB_PredeclaredId = True
  81. Attribute VB_Exposed = False
  82. Option Explicit
  83. Option Base 1
  84.  
  85. Private Const Iteration = 25
  86.  
  87. Dim IsLoaded         As Integer
  88.  
  89. Dim TimerStartOk     As Integer
  90. Dim TimerCloseOk     As Integer
  91.  
  92. Dim TimerHandle      As Integer
  93. Dim TimerValue       As Long
  94.  
  95. Private Sub cmb_Function_Click()
  96.    
  97.    If (IsLoaded = False) Then Exit Sub
  98.    
  99.    Call cDisableFI(mdiT2W.Picture1)
  100.    
  101.    txt_Result = ""
  102.    
  103.    DoEvents
  104.    
  105.    Select Case cmb_Function.ListIndex
  106.       Case 0
  107.          Call TestEnumPJ
  108.       Case 1
  109.          Call TestPrinterPrintableArea
  110.       Case 2
  111.          Call TestPrinterX
  112.       Case 3
  113.          Call TestEnumPrinters
  114.    End Select
  115.  
  116.    DoEvents
  117.    Call cEnableFI(mdiT2W.Picture1)
  118.    
  119. End Sub
  120.  
  121.  
  122. Private Sub cmdNP_Click(Index As Integer)
  123.  
  124.    Call sub_NextPrev(cmb_Function, Index)
  125.  
  126. End Sub
  127.  
  128. Private Sub Form_Activate()
  129.  
  130.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  131.  
  132. End Sub
  133.  
  134. Private Sub Form_Load()
  135.  
  136.    IsLoaded = False
  137.    
  138.    Show
  139.  
  140.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_printer.t2w")
  141.    
  142.    IsLoaded = True
  143.    
  144. End Sub
  145.  
  146. Private Sub Command1_Click()
  147.    
  148.    Call cmb_Function_Click
  149.    
  150. End Sub
  151.  
  152. Private Sub TestEnumPJ()
  153.  
  154.    Dim intResult        As Integer
  155.    Dim strDisplay       As String
  156.    
  157.    Dim i                As Integer
  158.    
  159.    strDisplay = ""
  160.    
  161.    Dim JI               As tagJOBINFO
  162.    
  163.    intResult = cEnumPrinterJobs("LPT1:", JI, True)
  164.    
  165.    Do While (intResult = EPJ_SUCCESS)
  166.    
  167.       strDisplay = strDisplay + "sPrinterName : '" & JI.sPrinterName & "'" & vbCrLf
  168.       strDisplay = strDisplay + "sMachineName : '" & JI.sMachineName & "'" & vbCrLf
  169.       strDisplay = strDisplay + "sUserName : '" & JI.sUserName & "'" & vbCrLf
  170.       strDisplay = strDisplay + "sDocument : '" & JI.sDocument & "'" & vbCrLf
  171.       strDisplay = strDisplay + "lJobId : " & JI.lJobId & vbCrLf
  172.       strDisplay = strDisplay + "lStatus : " & JI.lStatus & vbCrLf
  173.       strDisplay = strDisplay + "lPriority : " & JI.lPriority & vbCrLf
  174.       strDisplay = strDisplay + "lPosition : " & JI.lPosition & vbCrLf
  175.       strDisplay = strDisplay + "lStartTime : " & JI.lStartTime & vbCrLf
  176.       strDisplay = strDisplay + "lUntilTime : " & JI.lUntilTime & vbCrLf
  177.       strDisplay = strDisplay + "lTotalPages : " & JI.lTotalPages & vbCrLf
  178.       strDisplay = strDisplay + "lPagesPrinted : " & JI.lPagesPrinted & vbCrLf
  179.       strDisplay = strDisplay + "lSize : " & JI.lSize & vbCrLf
  180.       strDisplay = strDisplay + "lTime : " & JI.lTime & vbCrLf
  181.       strDisplay = strDisplay + "Submitted : " & JI.wMonth & "/" & JI.wDay & "/" & JI.wYear & " " & JI.wHour & ":" & JI.wMinute & ":" & JI.wSecond & vbCrLf & vbCrLf
  182.       
  183.       intResult = cEnumPrinterJobs("LPT1:", JI, False)
  184.    
  185.    Loop
  186.    
  187.    txt_Result = strDisplay
  188.  
  189.    'time the function
  190.  
  191.    TimerHandle = cTimerOpen()
  192.    TimerStartOk = cTimerStart(TimerHandle)
  193.    
  194.    For i = 1 To Iteration
  195.       intResult = cEnumPrinterJobs("LPT1:", JI, True)
  196.    Next i
  197.    
  198.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  199.    
  200.    TimerCloseOk = cTimerClose(TimerHandle)
  201.    
  202. End Sub
  203.  
  204. Private Sub TestPrinterPrintableArea()
  205.  
  206.    Dim intResult        As Integer
  207.    Dim strDisplay       As String
  208.    Dim sngResult        As Single
  209.    
  210.    Dim i                As Integer
  211.    
  212.    strDisplay = ""
  213.    
  214.    strDisplay = strDisplay + "Printer width : " & cPrinterWidth(Printer.hDC) & vbCrLf
  215.    strDisplay = strDisplay + "Printer height : " & cPrinterHeight(Printer.hDC) & vbCrLf
  216.    strDisplay = strDisplay + "Printer offset left : " & cPrinterOffsetLeft(Printer.hDC) & vbCrLf
  217.    strDisplay = strDisplay + "Printer offset top : " & cPrinterOffsetTop(Printer.hDC) & vbCrLf
  218.    
  219.    txt_Result = strDisplay
  220.  
  221.    'time the function
  222.  
  223.    TimerHandle = cTimerOpen()
  224.    TimerStartOk = cTimerStart(TimerHandle)
  225.    
  226.    For i = 1 To Iteration
  227.       sngResult = cPrinterWidth(Printer.hDC)
  228.    Next i
  229.    
  230.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  231.    
  232.    TimerCloseOk = cTimerClose(TimerHandle)
  233.    
  234. End Sub
  235.  
  236. Private Sub TestPrinterX()
  237.  
  238.    Dim intResult        As Integer
  239.    Dim strDisplay       As String
  240.    Dim sngResult        As Single
  241.    
  242.    Dim i                As Integer
  243.    Dim iValue           As Integer
  244.    
  245.    Dim iCopies          As Integer
  246.    Dim iDefaultSource   As Integer
  247.    Dim iDitherType      As Integer
  248.    Dim iOrientation     As Integer
  249.    Dim iPaper           As Integer
  250.    Dim iQuality         As Integer
  251.    
  252.    strDisplay = ""
  253.    
  254.    strDisplay = strDisplay + "GetPrinter informations " & vbCrLf & vbCrLf
  255.    
  256.    intResult = cGetPrinterCopies("LPT1:", iCopies)
  257.    strDisplay = strDisplay + "   Copies = " & iCopies & vbCrLf
  258.    intResult = cGetPrinterDefaultSource("LPT1:", iDefaultSource)
  259.    strDisplay = strDisplay + "   Default Source = " & iDefaultSource & vbCrLf
  260.    intResult = cGetPrinterDitherType("LPT1:", iDitherType)
  261.    strDisplay = strDisplay + "   Dither Type = " & iDitherType & vbCrLf
  262.    intResult = cGetPrinterOrientation("LPT1:", iOrientation)
  263.    strDisplay = strDisplay + "   Orientation = " & iOrientation & vbCrLf
  264.    intResult = cGetPrinterPaper("LPT1:", iPaper)
  265.    strDisplay = strDisplay + "   Paper = " & iPaper & vbCrLf
  266.    intResult = cGetPrinterQuality("LPT1:", iQuality)
  267.    strDisplay = strDisplay + "   Quality = " & iQuality & vbCrLf & vbCrLf
  268.    
  269.    strDisplay = strDisplay + "SetPrinter informations " & vbCrLf & vbCrLf
  270.    
  271.    intResult = cSetPrinterCopies("LPT1:", 7)
  272.    strDisplay = strDisplay + "   Set Copies to 7 = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  273.    intResult = cSetPrinterDefaultSource("LPT1:", SP_SOURCE_LOWER)
  274.    strDisplay = strDisplay + "   Set DefaultSource to SP_SOURCE_LOWER = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  275.    intResult = cSetPrinterDitherType("LPT1:", SP_DITHER_LINEART)
  276.    strDisplay = strDisplay + "   Set DitherType to SP_DITHER_LINEART = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  277.    intResult = cSetPrinterOrientation("LPT1:", SP_ORIENTATION_LANDSCAPE)
  278.    strDisplay = strDisplay + "   Set Orientation to SP_ORIENTATION_LANDSCAPE = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  279.    intResult = cSetPrinterQuality("LPT1:", SP_QUALITY_HIGH)
  280.    strDisplay = strDisplay + "   Set Quality to SP_QUALITY_HIGH = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf & vbCrLf
  281.    
  282.    strDisplay = strDisplay + "GetPrinter informations after modifications" & vbCrLf & vbCrLf
  283.    
  284.    intResult = cGetPrinterCopies("LPT1:", iValue)
  285.    strDisplay = strDisplay + "   Copies = " & iValue & vbCrLf
  286.    intResult = cGetPrinterDefaultSource("LPT1:", iValue)
  287.    strDisplay = strDisplay + "   Default Source = " & iValue & vbCrLf
  288.    intResult = cGetPrinterDitherType("LPT1:", iValue)
  289.    strDisplay = strDisplay + "   Dither Type = " & iValue & vbCrLf
  290.    intResult = cGetPrinterOrientation("LPT1:", iValue)
  291.    strDisplay = strDisplay + "   Orientation = " & iValue & vbCrLf
  292.    intResult = cGetPrinterPaper("LPT1:", iValue)
  293.    strDisplay = strDisplay + "   Paper = " & iValue & vbCrLf
  294.    intResult = cGetPrinterQuality("LPT1:", iValue)
  295.    strDisplay = strDisplay + "   Quality = " & iValue & vbCrLf & vbCrLf
  296.    
  297.    strDisplay = strDisplay + "Restore printer informations " & vbCrLf & vbCrLf
  298.    
  299.    intResult = cSetPrinterCopies("LPT1:", iCopies)
  300.    strDisplay = strDisplay + "   Set Copies to " & iCopies & " = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  301.    intResult = cSetPrinterDefaultSource("LPT1:", iDefaultSource)
  302.    strDisplay = strDisplay + "   Set DefaultSource to " & iDefaultSource & " = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  303.    intResult = cSetPrinterDitherType("LPT1:", iDitherType)
  304.    strDisplay = strDisplay + "   Set DitherType to " & iDitherType & " = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  305.    intResult = cSetPrinterOrientation("LPT1:", iOrientation)
  306.    strDisplay = strDisplay + "   Set Orientation to " & iOrientation & " = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf
  307.    intResult = cSetPrinterQuality("LPT1:", iQuality)
  308.    strDisplay = strDisplay + "   Set Quality to " & iQuality & " = " & IIf(intResult = SP_SUCCESS, "ok", "ko") & vbCrLf & vbCrLf
  309.    
  310.    strDisplay = strDisplay + "Read again GetPrinter informations " & vbCrLf & vbCrLf
  311.    
  312.    intResult = cGetPrinterCopies("LPT1:", iCopies)
  313.    strDisplay = strDisplay + "   Copies = " & iCopies & vbCrLf
  314.    intResult = cGetPrinterDefaultSource("LPT1:", iDefaultSource)
  315.    strDisplay = strDisplay + "   Default Source = " & iDefaultSource & vbCrLf
  316.    intResult = cGetPrinterDitherType("LPT1:", iDitherType)
  317.    strDisplay = strDisplay + "   Dither Type = " & iDitherType & vbCrLf
  318.    intResult = cGetPrinterOrientation("LPT1:", iOrientation)
  319.    strDisplay = strDisplay + "   Orientation = " & iOrientation & vbCrLf
  320.    intResult = cGetPrinterPaper("LPT1:", iPaper)
  321.    strDisplay = strDisplay + "   Paper = " & iPaper & vbCrLf
  322.    intResult = cGetPrinterQuality("LPT1:", iQuality)
  323.    strDisplay = strDisplay + "   Quality = " & iQuality & vbCrLf & vbCrLf
  324.    
  325.    txt_Result = strDisplay
  326.  
  327.    'time the function
  328.  
  329.    TimerHandle = cTimerOpen()
  330.    TimerStartOk = cTimerStart(TimerHandle)
  331.    
  332.    For i = 1 To Iteration
  333.       intResult = cGetPrinterCopies("LPT1:", iValue)
  334.    Next i
  335.    
  336.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  337.    
  338.    TimerCloseOk = cTimerClose(TimerHandle)
  339.    
  340. End Sub
  341.  
  342. Private Sub TestEnumPrinters()
  343.  
  344.    Dim intResult        As Integer
  345.    Dim strDisplay       As String
  346.    Dim P1               As tagPRINTER1
  347.    Dim P2               As tagPRINTER2
  348.    Dim P5               As tagPRINTER5
  349.    
  350.    Dim i                As Integer
  351.    
  352.    strDisplay = ""
  353.    
  354.    strDisplay = strDisplay & "EnumPrinters1" & vbCrLf & vbCrLf
  355.    
  356.    intResult = cEnumPrinters1(P1, True)
  357.    
  358.    Do While (intResult = EP_SUCCESS)
  359.    
  360.       strDisplay = strDisplay + "sPrinterName : '" & P1.sPrinterName & "'" & vbCrLf
  361.       strDisplay = strDisplay + "sDescription : '" & P1.sDescription & "'" & vbCrLf
  362.       strDisplay = strDisplay + "sComment : '" & P1.sComment & "'" & vbCrLf & vbCrLf
  363.       
  364.       intResult = cEnumPrinters1(P1, False)
  365.    
  366.    Loop
  367.    
  368.    strDisplay = strDisplay + vbCrLf + "EnumPrinters5" & vbCrLf & vbCrLf
  369.    
  370.    intResult = cEnumPrinters5(P5, True)
  371.    
  372.    Do While (intResult = EP_SUCCESS)
  373.    
  374.       strDisplay = strDisplay + "sPrinterName : '" & P5.sPrinterName & "'" & vbCrLf
  375.       strDisplay = strDisplay + "sPortName : '" & P5.sPortName & "'" & vbCrLf & vbCrLf
  376.       
  377.       intResult = cEnumPrinters5(P5, False)
  378.    
  379.    Loop
  380.    
  381.    txt_Result = strDisplay
  382.  
  383.    'time the function
  384.  
  385.    TimerHandle = cTimerOpen()
  386.    TimerStartOk = cTimerStart(TimerHandle)
  387.    
  388.    For i = 1 To Iteration
  389.       intResult = cEnumPrinters1(P1, True)
  390.    Next i
  391.    
  392.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  393.    
  394.    TimerCloseOk = cTimerClose(TimerHandle)
  395.    
  396. End Sub
  397.  
  398.