home *** CD-ROM | disk | FTP | other *** search
/ Zodiac Super OZ / MEDIADEPOT.ISO / FILES / 13 / VBPRNT20.ZIP / VB4 / VBPRNT32.FRM (.txt) < prev   
Visual Basic Form  |  1996-05-31  |  12KB  |  348 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMain 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "VBPrint Functions"
  6.    ClientHeight    =   4230
  7.    ClientLeft      =   1665
  8.    ClientTop       =   3090
  9.    ClientWidth     =   6240
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   0
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   4665
  21.    Left            =   1605
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   4230
  24.    ScaleWidth      =   6240
  25.    Top             =   2715
  26.    Width           =   6360
  27.    Begin VB.Frame Frame1 
  28.       Appearance      =   0  'Flat
  29.       BackColor       =   &H00C0C0C0&
  30.       Caption         =   "Printer Features"
  31.       ForeColor       =   &H80000008&
  32.       Height          =   1695
  33.       Left            =   0
  34.       TabIndex        =   11
  35.       Top             =   2460
  36.       Width           =   6180
  37.       Begin VB.ListBox lstRes 
  38.          Appearance      =   0  'Flat
  39.          Height          =   615
  40.          Left            =   5025
  41.          TabIndex        =   17
  42.          Top             =   420
  43.          Width           =   975
  44.       End
  45.       Begin VB.ListBox lstBins 
  46.          Appearance      =   0  'Flat
  47.          Height          =   615
  48.          Left            =   3135
  49.          TabIndex        =   15
  50.          Top             =   420
  51.          Width           =   1785
  52.       End
  53.       Begin VB.ListBox lstPapers 
  54.          Appearance      =   0  'Flat
  55.          Height          =   1200
  56.          Left            =   135
  57.          TabIndex        =   12
  58.          Top             =   420
  59.          Width           =   2940
  60.       End
  61.       Begin VB.Label Label1 
  62.          Appearance      =   0  'Flat
  63.          AutoSize        =   -1  'True
  64.          BackColor       =   &H80000005&
  65.          BackStyle       =   0  'Transparent
  66.          Caption         =   "Resolutions"
  67.          ForeColor       =   &H80000008&
  68.          Height          =   195
  69.          Index           =   5
  70.          Left            =   5025
  71.          TabIndex        =   16
  72.          Top             =   195
  73.          Width           =   1005
  74.       End
  75.       Begin VB.Label Label1 
  76.          Appearance      =   0  'Flat
  77.          AutoSize        =   -1  'True
  78.          BackColor       =   &H80000005&
  79.          BackStyle       =   0  'Transparent
  80.          Caption         =   "Paper bins"
  81.          ForeColor       =   &H80000008&
  82.          Height          =   195
  83.          Index           =   4
  84.          Left            =   3120
  85.          TabIndex        =   14
  86.          Top             =   195
  87.          Width           =   915
  88.       End
  89.       Begin VB.Label Label1 
  90.          Appearance      =   0  'Flat
  91.          AutoSize        =   -1  'True
  92.          BackColor       =   &H80000005&
  93.          BackStyle       =   0  'Transparent
  94.          Caption         =   "Paper types"
  95.          ForeColor       =   &H80000008&
  96.          Height          =   195
  97.          Index           =   3
  98.          Left            =   135
  99.          TabIndex        =   13
  100.          Top             =   195
  101.          Width           =   1020
  102.       End
  103.    End
  104.    Begin VB.CheckBox chkDefault 
  105.       Appearance      =   0  'Flat
  106.       BackColor       =   &H00C0C0C0&
  107.       Caption         =   "Use Windows defaults in dialog"
  108.       ForeColor       =   &H80000008&
  109.       Height          =   195
  110.       Left            =   75
  111.       TabIndex        =   5
  112.       Top             =   2175
  113.       Width           =   3510
  114.    End
  115.    Begin VB.CheckBox chkPerm 
  116.       Appearance      =   0  'Flat
  117.       BackColor       =   &H00C0C0C0&
  118.       Caption         =   "Make changes permanent"
  119.       ForeColor       =   &H80000008&
  120.       Height          =   195
  121.       Left            =   75
  122.       TabIndex        =   4
  123.       Top             =   1920
  124.       Width           =   2910
  125.    End
  126.    Begin VB.Timer Timer1 
  127.       Enabled         =   0   'False
  128.       Interval        =   1000
  129.       Left            =   6015
  130.       Top             =   9670
  131.    End
  132.    Begin VB.CommandButton cmdBtn 
  133.       Appearance      =   0  'Flat
  134.       BackColor       =   &H80000005&
  135.       Caption         =   "E&xit"
  136.       Height          =   330
  137.       Index           =   2
  138.       Left            =   4710
  139.       TabIndex        =   3
  140.       Top             =   1560
  141.       Width           =   1365
  142.    End
  143.    Begin VB.CommandButton cmdBtn 
  144.       Appearance      =   0  'Flat
  145.       BackColor       =   &H80000005&
  146.       Caption         =   "Show &Dialog"
  147.       Height          =   330
  148.       Index           =   1
  149.       Left            =   4710
  150.       TabIndex        =   2
  151.       Top             =   1170
  152.       Width           =   1365
  153.    End
  154.    Begin VB.CommandButton cmdBtn 
  155.       Appearance      =   0  'Flat
  156.       BackColor       =   &H80000005&
  157.       Caption         =   "&Set Default"
  158.       Height          =   330
  159.       Index           =   0
  160.       Left            =   4710
  161.       TabIndex        =   1
  162.       Top             =   780
  163.       Width           =   1365
  164.    End
  165.    Begin VB.ListBox lstPrinters 
  166.       Appearance      =   0  'Flat
  167.       Height          =   1590
  168.       Left            =   60
  169.       TabIndex        =   0
  170.       Top             =   255
  171.       Width           =   3270
  172.    End
  173.    Begin VB.Label lblDefDriver 
  174.       Appearance      =   0  'Flat
  175.       BackColor       =   &H00FFFFFF&
  176.       BackStyle       =   0  'Transparent
  177.       ForeColor       =   &H00FFFFFF&
  178.       Height          =   195
  179.       Left            =   4050
  180.       TabIndex        =   10
  181.       Top             =   510
  182.       Width           =   1410
  183.    End
  184.    Begin VB.Label Label1 
  185.       Appearance      =   0  'Flat
  186.       AutoSize        =   -1  'True
  187.       BackColor       =   &H80000005&
  188.       BackStyle       =   0  'Transparent
  189.       Caption         =   "Driver:"
  190.       ForeColor       =   &H80000008&
  191.       Height          =   195
  192.       Index           =   2
  193.       Left            =   3420
  194.       TabIndex        =   9
  195.       Top             =   525
  196.       Width           =   585
  197.    End
  198.    Begin VB.Label lblDefault 
  199.       Appearance      =   0  'Flat
  200.       BackColor       =   &H00FFFFFF&
  201.       BackStyle       =   0  'Transparent
  202.       ForeColor       =   &H00FFFFFF&
  203.       Height          =   195
  204.       Left            =   3420
  205.       TabIndex        =   8
  206.       Top             =   270
  207.       Width           =   2610
  208.    End
  209.    Begin VB.Label Label1 
  210.       Appearance      =   0  'Flat
  211.       AutoSize        =   -1  'True
  212.       BackColor       =   &H80000005&
  213.       BackStyle       =   0  'Transparent
  214.       Caption         =   "Current default printer:"
  215.       ForeColor       =   &H80000008&
  216.       Height          =   195
  217.       Index           =   1
  218.       Left            =   3420
  219.       TabIndex        =   7
  220.       Top             =   30
  221.       Width           =   1935
  222.    End
  223.    Begin VB.Label Label1 
  224.       Appearance      =   0  'Flat
  225.       AutoSize        =   -1  'True
  226.       BackColor       =   &H80000005&
  227.       BackStyle       =   0  'Transparent
  228.       Caption         =   "Installed printers"
  229.       ForeColor       =   &H80000008&
  230.       Height          =   195
  231.       Index           =   0
  232.       Left            =   60
  233.       TabIndex        =   6
  234.       Top             =   30
  235.       Width           =   1425
  236.    End
  237. Attribute VB_Name = "frmMain"
  238. Attribute VB_Creatable = False
  239. Attribute VB_Exposed = False
  240. DefInt I
  241. DefLng L
  242. DefStr S
  243. Option Explicit
  244. Dim Shared DeviceData() As DEVMODE_TYPE
  245. Private Sub cmdBtn_Click(Index As Integer)
  246.   Dim iRet As Integer
  247.   Dim inMode As DEVMODE_TYPE
  248.   Dim outMode As DEVMODE_TYPE
  249.   Dim sTemp As String
  250.   Dim iMode As Integer
  251.   Dim sTemp2 As String
  252.   Select Case Index
  253.     Case 0
  254.       If lstPrinters.ListIndex = True Then Exit Sub
  255.       sTemp = lstPrinters.List(lstPrinters.ListIndex)
  256.       iRet = VBSetDefPrinter(sTemp)
  257.       If iRet <> True Then MsgBox "Error setting default printer", 48, "Error"
  258.       Timer1_Timer
  259.     Case 1
  260.       If lstPrinters.ListIndex = True Then Exit Sub
  261.       sTemp = lstPrinters.List(lstPrinters.ListIndex)
  262.       iMode = DM_OUT_BUFFER Or DM_IN_PROMPT
  263.       If chkPerm.Value <> 0 Then iMode = iMode Or DM_OUT_DEFAULT
  264.       If chkDefault.Value = 0 Then iMode = iMode Or DM_IN_BUFFER
  265.       sTemp2 = VBDevModeToStr(DeviceData(lstPrinters.ListIndex))
  266.       iRet = VBExtDeviceMode(0, sTemp, DeviceData(lstPrinters.ListIndex), outMode, iMode)
  267.       If iRet = 1 Then iRet = VBStrToDevMode(VBDevModeToStr(outMode), DeviceData(lstPrinters.ListIndex))
  268.         
  269.     Case 2
  270.       End
  271.   End Select
  272. End Sub
  273. Private Sub Form_Load()
  274.   Dim sTemp As String
  275.   Dim inMode As DEVMODE_TYPE
  276.   Dim iRet As Integer
  277.   Me.Left = Screen.Width / 2 - Me.Width / 2
  278.   Me.Top = Screen.Height / 2 - Me.Height / 2
  279.   sTemp = VBGetPrinters()
  280.   While sTemp <> ""
  281.     ReDim Preserve DeviceData(lstPrinters.ListCount)
  282.     iRet = VBExtDeviceMode(0, sTemp, inMode, DeviceData(lstPrinters.ListCount), DM_OUT_BUFFER)
  283.     If iRet = 1 Then lstPrinters.AddItem sTemp
  284.     If iRet <> 1 Then MsgBox Str$(iRet), 32, "Rats"
  285.     sTemp = VBGetPrinters()
  286.   Wend
  287.   lstPrinters.ListIndex = 0
  288.   lstPrinters_Click
  289.   Timer1_Timer
  290. End Sub
  291. Private Sub lstPrinters_Click()
  292.   ShowOptions lstPrinters.List(lstPrinters.ListIndex) + ""
  293. End Sub
  294. Private Sub ShowOptions(sPrinter As String)
  295.   Dim resList() As ENUMRESOLUTIONS_TYPE
  296.   Dim binNameList() As BINNAMES_TYPE
  297.   Dim binNumList() As Integer
  298.   Dim papNameList() As PAPERNAMES_TYPE
  299.   Dim papSizeList() As PAPERSIZE_TYPE
  300.   Dim lRet As Long
  301.   Dim inDev As DEVMODE_TYPE
  302.   Dim iCounter As Integer
  303.   ' Step 1, find out how many paper sizes/names there are
  304.   lRet = VBDeviceCapabilities(sPrinter, DC_PAPERSIZE, ByVal 0&, inDev)
  305.   If lRet = 0 Then Exit Sub
  306.   ' Size our arrays accordingly
  307.   ReDim papSizeList(lRet - 1) As PAPERSIZE_TYPE
  308.   ReDim papNameList(lRet - 1) As PAPERNAMES_TYPE
  309.   papNameList(0).sName = "Test1"
  310.   papNameList(1).sName = "Test2"
  311.   ' Get the actual names of the available papers and their sizes
  312.   lRet = VBDeviceCapArray(sPrinter, DC_PAPERNAMES, papNameList(), inDev)
  313.   lRet = VBDeviceCapArray(sPrinter, DC_PAPERSIZE, papSizeList(), inDev)
  314.   ' Display the available paper types in a list
  315.   ' Note the papSizeList() is just for demonstration
  316.   ' purposes, I don't use it here but you may want to use
  317.   ' it for reference purposes.
  318.   lstPapers.Clear
  319.   For iCounter = 0 To lRet - 1
  320.     lstPapers.AddItem Trim$(papNameList(iCounter).sName)
  321.   Next
  322.   ' Same procedure for the available printer bins
  323.   lRet = VBDeviceCapabilities(sPrinter, DC_BINNAMES, ByVal 0&, inDev)
  324.   If lRet = 0 Then Exit Sub
  325.   ReDim binNameList(lRet - 1) As BINNAMES_TYPE
  326.   ReDim binNumList(lRet - 1) As Integer
  327.   lRet = VBDeviceCapArray(sPrinter, DC_BINS, binNumList(), inDev)
  328.   lRet = VBDeviceCapArray(sPrinter, DC_BINNAMES, binNameList(), inDev)
  329.   lstBins.Clear
  330.   For iCounter = 0 To lRet - 1
  331.     lstBins.AddItem Trim$(binNameList(iCounter).sName)
  332.   Next
  333.   lRet = VBDeviceCapabilities(sPrinter, DC_ENUMRESOLUTIONS, ByVal 0&, inDev)
  334.   If lRet = 0 Then Exit Sub
  335.   ReDim resList(lRet - 1) As ENUMRESOLUTIONS_TYPE
  336.   lRet = VBDeviceCapArray(sPrinter, DC_ENUMRESOLUTIONS, resList(), inDev)
  337.   lstRes.Clear
  338.   For iCounter = 0 To lRet - 1
  339.     lstRes.AddItem Format$(resList(iCounter).xdpi, "#") + " x " + Format$(resList(iCounter).ydpi, "#")
  340.   Next
  341. End Sub
  342. Private Sub Timer1_Timer()
  343.   Dim sTemp As String
  344.   sTemp = VBGetDefPrinter()
  345.   lblDefault.Caption = sTemp
  346.   lblDefDriver = VBGetDriverFromName(sTemp)
  347. End Sub
  348.