home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vb_g_prt / vbg1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  6.8 KB  |  229 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "VB General Printer"
  4.    ClientHeight    =   4665
  5.    ClientLeft      =   1170
  6.    ClientTop       =   1710
  7.    ClientWidth     =   7365
  8.    Height          =   5355
  9.    Icon            =   VBG1.FRX:0000
  10.    Left            =   1110
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   4665
  13.    ScaleWidth      =   7365
  14.    Top             =   1080
  15.    Width           =   7485
  16.    Begin CheckBox chkItalic 
  17.       Caption         =   "Italic"
  18.       Height          =   375
  19.       Left            =   3000
  20.       TabIndex        =   10
  21.       Top             =   1800
  22.       Width           =   1455
  23.    End
  24.    Begin CheckBox chkBold 
  25.       Caption         =   "Bold"
  26.       Height          =   375
  27.       Left            =   960
  28.       TabIndex        =   9
  29.       Top             =   1800
  30.       Width           =   1215
  31.    End
  32.    Begin ComboBox Combo2 
  33.       Height          =   300
  34.       Left            =   5280
  35.       TabIndex        =   8
  36.       Text            =   "Combo2"
  37.       Top             =   1320
  38.       Width           =   1575
  39.    End
  40.    Begin ComboBox Combo1 
  41.       Height          =   300
  42.       Left            =   720
  43.       TabIndex        =   7
  44.       Text            =   "Combo1"
  45.       Top             =   1320
  46.       Width           =   3255
  47.    End
  48.    Begin CommandButton cmdExit 
  49.       Caption         =   "E&xit"
  50.       Height          =   375
  51.       Left            =   4320
  52.       TabIndex        =   0
  53.       Top             =   4080
  54.       Width           =   1695
  55.    End
  56.    Begin CommandButton cmdPrint 
  57.       Caption         =   "&Print"
  58.       Height          =   375
  59.       Left            =   1440
  60.       TabIndex        =   4
  61.       Top             =   4080
  62.       Width           =   1695
  63.    End
  64.    Begin TextBox Text1 
  65.       Height          =   1455
  66.       Left            =   120
  67.       MultiLine       =   -1  'True
  68.       ScrollBars      =   3  'Both
  69.       TabIndex        =   3
  70.       Text            =   "Text1"
  71.       Top             =   2400
  72.       Width           =   7095
  73.    End
  74.    Begin Frame Frame1 
  75.       Caption         =   "Instructions:"
  76.       Height          =   1095
  77.       Left            =   120
  78.       TabIndex        =   1
  79.       Top             =   120
  80.       Width           =   7095
  81.       Begin Label Label1 
  82.          Caption         =   "Enter text in the box below.  Choose File|Print to print text or click on command button below.  Choose File|Printer Select... to choose new printer."
  83.          Height          =   735
  84.          Left            =   120
  85.          TabIndex        =   2
  86.          Top             =   240
  87.          Width           =   6855
  88.       End
  89.    End
  90.    Begin Label Label3 
  91.       Caption         =   "Font Size:"
  92.       Height          =   375
  93.       Left            =   4200
  94.       TabIndex        =   6
  95.       Top             =   1320
  96.       Width           =   1215
  97.    End
  98.    Begin Label Label2 
  99.       Caption         =   "Font:"
  100.       Height          =   375
  101.       Left            =   120
  102.       TabIndex        =   5
  103.       Top             =   1320
  104.       Width           =   735
  105.    End
  106.    Begin Menu mnuFile 
  107.       Caption         =   "&File"
  108.       Begin Menu mnuPrinterSelect 
  109.          Caption         =   "Printer &Select..."
  110.       End
  111.       Begin Menu mnuPrint 
  112.          Caption         =   "&Print"
  113.       End
  114.       Begin Menu mnuSep1 
  115.          Caption         =   "-"
  116.       End
  117.       Begin Menu mnuExit 
  118.          Caption         =   "E&xit"
  119.       End
  120.    End
  121.    Begin Menu mnuHelp 
  122.       Caption         =   "&Help"
  123.       Begin Menu mnuAbout 
  124.          Caption         =   "&About VBGPRINT"
  125.       End
  126.    End
  127. '----------------------------------------------------------------
  128. 'Copyright 1994   Unger Business Systems  All Rights Reserved
  129. 'This code is distributed as shareware.  If you use it, you
  130. 'are required by law to register it.  Please contact Unger
  131. 'Business Systems at 11926 Barrett Brae, Houston, TX 77072-4004
  132. 'or call (713) 498-8517.  Registration fee is $20.00 US
  133. 'See the README.TXT file for more information
  134. 'All code, forms, modules, controls, etc. are provided without
  135. 'warranty or liability
  136. '----------------------------------------------------------------
  137. Option Explicit
  138. Dim UseBold%, UseItalic%
  139. Sub cmdExit_Click ()
  140.    mnuExit_Click
  141. End Sub
  142. Sub cmdPrint_Click ()
  143.    mnuPrint_Click
  144. End Sub
  145. Sub Combo1_Click ()
  146.     Dim Pos%, TStr$
  147.     'if chosen font has BOLD or ITALIC in its name, set the
  148.     'appropriate check box
  149.     TStr = UCase$(Combo1.Text)
  150.     Pos = InStr(1, TStr, "BOLD")
  151.     If Pos > 0 Then
  152.         chkBold = 1
  153.     Else
  154.         chkBold = 0
  155.     End If
  156.     Pos = InStr(1, TStr, "ITALIC")
  157.     If Pos > 0 Then
  158.         chkItalic = 1
  159.     Else
  160.         chkItalic = 0
  161.     End If
  162. End Sub
  163. Sub FillCombo1 ()
  164.     'This routine reads all of the installed fonts and
  165.     'stores them as choices in the combo box
  166.     Dim InstalledFonts$, OldPos%, Counter%, Pos%, I%
  167.     Dim IPos%, ThisFont$
  168.     InstalledFonts = Space$(4096)
  169.    'Calling GetProfileString with 0& as the second parameter returns a list
  170.    'of all items in the "fonts" section of WIN.INI
  171.    'These are separated by ASCII 0's and must be parsed
  172.     I% = GetProfileString("fonts", 0&, "none", InstalledFonts, Len(InstalledFonts))
  173.     InstalledFonts = Left$(InstalledFonts, I%)
  174.     If InstalledFonts = "none" Then
  175.         MsgBox "No Windows fonts installed.", MB_ICONSTOP
  176.         Exit Sub
  177.     End If
  178.     OldPos% = 1
  179.     Counter = 1
  180.     Do While 1
  181.         IPos% = InStr(OldPos%, InstalledFonts, Chr$(0))
  182.         If IPos% > 0 Then
  183.             ThisFont = Mid$(InstalledFonts, OldPos%, IPos% - OldPos%)
  184.             Combo1.AddItem ThisFont
  185.             OldPos% = IPos% + 1
  186.         Else
  187.             Exit Do
  188.         End If
  189.     Loop
  190.     Combo1.ListIndex = 0
  191. End Sub
  192. Sub FillCombo2 ()
  193.    Combo2.Clear
  194.    Combo2.AddItem "6"
  195.    Combo2.AddItem "8"
  196.    Combo2.AddItem "10"
  197.    Combo2.AddItem "12"
  198.    Combo2.AddItem "14"
  199.    Combo2.AddItem "18"
  200.    Combo2.AddItem "24"
  201.    Combo2.AddItem "36"
  202.    Combo2.AddItem "48"
  203.    Combo2.ListIndex = 2
  204. End Sub
  205. Sub Form_Load ()
  206.     CRLF = Chr$(13) & Chr$(10)
  207.     Text1 = ""
  208.     'Get the default windows printer for a starting point
  209.     ThisPrinter = GetWindowsDefaultPrinter()
  210.     ThisOrientation = GetWindowsPrinterOrientation(ThisPrinter)
  211.     FillCombo1  'available fonts
  212.     FillCombo2  'some font sizes
  213. End Sub
  214. Sub Form_Unload (Cancel As Integer)
  215.     End
  216. End Sub
  217. Sub mnuAbout_Click ()
  218.    frmAbout.Show 1 'modal
  219. End Sub
  220. Sub mnuExit_Click ()
  221.    Unload Me
  222. End Sub
  223. Sub mnuPrint_Click ()
  224.     PrintThisText Text1, Combo1.Text, Val(Combo2.Text), UseBold, UseItalic
  225. End Sub
  226. Sub mnuPrinterSelect_Click ()
  227.     SelectPrinter ThisPrinter, ThisOrientation, "VBG Printer"
  228. End Sub
  229.