home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / RTPrintPre181714102001.psc / RTPreview.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-04-10  |  12.0 KB  |  321 lines

  1. VERSION 5.00
  2. Begin VB.Form frmRTPreview 
  3.    BackColor       =   &H8000000B&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Print preview"
  6.    ClientHeight    =   6435
  7.    ClientLeft      =   1125
  8.    ClientTop       =   1500
  9.    ClientWidth     =   9780
  10.    Icon            =   "RTPreview.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    PaletteMode     =   1  'UseZOrder
  16.    ScaleHeight     =   429
  17.    ScaleMode       =   3  'Pixel
  18.    ScaleWidth      =   652
  19.    Begin VB.CommandButton cmdClose 
  20.       BeginProperty Font 
  21.          Name            =   "Arial"
  22.          Size            =   8.25
  23.          Charset         =   0
  24.          Weight          =   700
  25.          Underline       =   0   'False
  26.          Italic          =   0   'False
  27.          Strikethrough   =   0   'False
  28.       EndProperty
  29.       Height          =   405
  30.       Left            =   8310
  31.       Picture         =   "RTPreview.frx":030A
  32.       Style           =   1  'Graphical
  33.       TabIndex        =   17
  34.       Top             =   30
  35.       Width           =   1005
  36.    End
  37.    Begin VB.CommandButton cmdZoomOut 
  38.       Height          =   405
  39.       Left            =   210
  40.       Picture         =   "RTPreview.frx":12C4
  41.       Style           =   1  'Graphical
  42.       TabIndex        =   16
  43.       ToolTipText     =   "Zoom out"
  44.       Top             =   60
  45.       Width           =   405
  46.    End
  47.    Begin VB.CommandButton cmdZoomIn 
  48.       Height          =   405
  49.       Left            =   630
  50.       Picture         =   "RTPreview.frx":13C6
  51.       Style           =   1  'Graphical
  52.       TabIndex        =   15
  53.       ToolTipText     =   "Zoom in"
  54.       Top             =   60
  55.       Width           =   405
  56.    End
  57.    Begin VB.CommandButton cmdPrint 
  58.       Height          =   405
  59.       Left            =   7170
  60.       Picture         =   "RTPreview.frx":14C8
  61.       Style           =   1  'Graphical
  62.       TabIndex        =   14
  63.       ToolTipText     =   "Print"
  64.       Top             =   30
  65.       Width           =   405
  66.    End
  67.    Begin VB.ComboBox cboScale 
  68.       BeginProperty Font 
  69.          Name            =   "MS Sans Serif"
  70.          Size            =   9.75
  71.          Charset         =   0
  72.          Weight          =   400
  73.          Underline       =   0   'False
  74.          Italic          =   0   'False
  75.          Strikethrough   =   0   'False
  76.       EndProperty
  77.       Height          =   360
  78.       Left            =   1050
  79.       Style           =   2  'Dropdown List
  80.       TabIndex        =   13
  81.       Top             =   60
  82.       Width           =   855
  83.    End
  84.    Begin VB.CommandButton cmdPrevPage 
  85.       Caption         =   "<"
  86.       BeginProperty Font 
  87.          Name            =   "MS Sans Serif"
  88.          Size            =   9.75
  89.          Charset         =   0
  90.          Weight          =   700
  91.          Underline       =   0   'False
  92.          Italic          =   0   'False
  93.          Strikethrough   =   0   'False
  94.       EndProperty
  95.       Height          =   375
  96.       Left            =   2730
  97.       TabIndex        =   12
  98.       ToolTipText     =   "Prev page"
  99.       Top             =   60
  100.       Width           =   345
  101.    End
  102.    Begin VB.CommandButton cmdNextPage 
  103.       Caption         =   ">"
  104.       BeginProperty Font 
  105.          Name            =   "MS Sans Serif"
  106.          Size            =   9.75
  107.          Charset         =   0
  108.          Weight          =   700
  109.          Underline       =   0   'False
  110.          Italic          =   0   'False
  111.          Strikethrough   =   0   'False
  112.       EndProperty
  113.       Height          =   375
  114.       Left            =   3090
  115.       TabIndex        =   11
  116.       ToolTipText     =   "Next page"
  117.       Top             =   60
  118.       Width           =   345
  119.    End
  120.    Begin VB.ComboBox cboPageNo 
  121.       BeginProperty Font 
  122.          Name            =   "MS Sans Serif"
  123.          Size            =   9.75
  124.          Charset         =   0
  125.          Weight          =   400
  126.          Underline       =   0   'False
  127.          Italic          =   0   'False
  128.          Strikethrough   =   0   'False
  129.       EndProperty
  130.       Height          =   360
  131.       Left            =   3450
  132.       Style           =   2  'Dropdown List
  133.       TabIndex        =   10
  134.       Top             =   60
  135.       Width           =   825
  136.    End
  137.    Begin VB.PictureBox PicZ 
  138.       BackColor       =   &H8000000D&
  139.       Height          =   5325
  140.       Left            =   60
  141.       ScaleHeight     =   5265
  142.       ScaleWidth      =   9285
  143.       TabIndex        =   2
  144.       Top             =   720
  145.       Width           =   9345
  146.       Begin VB.PictureBox Pic5 
  147.          BackColor       =   &H80000009&
  148.          Height          =   2295
  149.          Left            =   120
  150.          ScaleHeight     =   2235
  151.          ScaleWidth      =   2595
  152.          TabIndex        =   9
  153.          Top             =   120
  154.          Width           =   2655
  155.       End
  156.       Begin VB.PictureBox Pic4 
  157.          AutoRedraw      =   -1  'True
  158.          BackColor       =   &H80000009&
  159.          Height          =   2715
  160.          Left            =   150
  161.          ScaleHeight     =   2655
  162.          ScaleWidth      =   3015
  163.          TabIndex        =   8
  164.          Top             =   120
  165.          Width           =   3075
  166.       End
  167.       Begin VB.PictureBox Pic3 
  168.          AutoRedraw      =   -1  'True
  169.          BackColor       =   &H80000009&
  170.          Height          =   3285
  171.          Left            =   120
  172.          ScaleHeight     =   3225
  173.          ScaleWidth      =   3765
  174.          TabIndex        =   7
  175.          Top             =   90
  176.          Width           =   3825
  177.       End
  178.       Begin VB.PictureBox Pic2 
  179.          AutoRedraw      =   -1  'True
  180.          BackColor       =   &H80000009&
  181.          Height          =   3795
  182.          Left            =   90
  183.          ScaleHeight     =   3735
  184.          ScaleWidth      =   4515
  185.          TabIndex        =   6
  186.          Top             =   60
  187.          Width           =   4575
  188.       End
  189.       Begin VB.PictureBox Pic1 
  190.          AutoRedraw      =   -1  'True
  191.          BackColor       =   &H80000009&
  192.          Height          =   4215
  193.          Left            =   60
  194.          ScaleHeight     =   4155
  195.          ScaleWidth      =   5325
  196.          TabIndex        =   5
  197.          Top             =   30
  198.          Width           =   5385
  199.       End
  200.       Begin VB.PictureBox PicX 
  201.          AutoRedraw      =   -1  'True
  202.          BackColor       =   &H80000009&
  203.          Height          =   4695
  204.          Left            =   30
  205.          ScaleHeight     =   4635
  206.          ScaleWidth      =   6015
  207.          TabIndex        =   4
  208.          Top             =   0
  209.          Width           =   6075
  210.       End
  211.       Begin VB.PictureBox picP 
  212.          AutoRedraw      =   -1  'True
  213.          BackColor       =   &H80000009&
  214.          Height          =   5310
  215.          Left            =   0
  216.          ScaleHeight     =   5250
  217.          ScaleWidth      =   6885
  218.          TabIndex        =   3
  219.          Top             =   -30
  220.          Width           =   6945
  221.       End
  222.    End
  223.    Begin VB.VScrollBar VScroll1 
  224.       Height          =   5295
  225.       Left            =   9420
  226.       Max             =   500
  227.       TabIndex        =   0
  228.       TabStop         =   0   'False
  229.       Top             =   720
  230.       Width           =   270
  231.    End
  232.    Begin VB.HScrollBar HScroll1 
  233.       Height          =   255
  234.       Left            =   60
  235.       Max             =   500
  236.       TabIndex        =   1
  237.       TabStop         =   0   'False
  238.       Top             =   6060
  239.       Width           =   9345
  240.    End
  241.    Begin VB.Label lblPercent 
  242.       Caption         =   "%"
  243.       BeginProperty Font 
  244.          Name            =   "MS Sans Serif"
  245.          Size            =   8.25
  246.          Charset         =   0
  247.          Weight          =   700
  248.          Underline       =   0   'False
  249.          Italic          =   0   'False
  250.          Strikethrough   =   0   'False
  251.       EndProperty
  252.       Height          =   225
  253.       Left            =   1950
  254.       TabIndex        =   19
  255.       Top             =   120
  256.       Width           =   315
  257.    End
  258.    Begin VB.Label lblTotalPages 
  259.       Caption         =   "lblTotalPages"
  260.       BeginProperty Font 
  261.          Name            =   "MS Sans Serif"
  262.          Size            =   9.75
  263.          Charset         =   0
  264.          Weight          =   400
  265.          Underline       =   0   'False
  266.          Italic          =   0   'False
  267.          Strikethrough   =   0   'False
  268.       EndProperty
  269.       Height          =   285
  270.       Left            =   4350
  271.       TabIndex        =   18
  272.       Top             =   120
  273.       Width           =   1875
  274.    End
  275. Attribute VB_Name = "frmRTPreview"
  276. Attribute VB_GlobalNameSpace = False
  277. Attribute VB_Creatable = False
  278. Attribute VB_PredeclaredId = True
  279. Attribute VB_Exposed = False
  280. '  RTPreview.frm  (Also known as DocPreview)
  281. '  By Herman Liu
  282. '  A functional program to provide print preview and actual printing facilities for RichText
  283. '  documents in a text editor. Written in VB, the program includes functions such as preview
  284. '  Zoom-in and Zoom-out, page margins setup, selection of any specific page to preview and
  285. '  selection of any range of pages to print.  It even allows you to selectively print a
  286. '  highlighted text and/or picture only, etc.
  287. '  Though there are a few print preview programs around, I have not come across any which is
  288. '  geared for RTB in VB context (If a programmer has to arbitrarily apply his/her own fonts,
  289. '  the resultant printouts would never be able to reflect the document's original settings).
  290. '  Despite VB does not have something like MFC, and despite the many constraints of RTB, we
  291. '  we will see that we are able to add functions for a print preview &/or for printing
  292. '  page(s) selectively. This RTPreview shows how.
  293. '  The Source code is written in native VB. Forms and controls involved are: (1) MDI
  294. '  called frmRTFrame. A child form, called RTDoc, which contains a RTB (a hidden RTB and
  295. '  a hidden picturebox for use in printing highlighted text/picture only). It is from this
  296. '  child form that the RTPreview is invoked . (2) a form for preview, with MDIChild property
  297. '  set to False.  This RTPreview contains a "home-made" viewport which consists of several
  298. '  pictureboxes.  Controls placed outside the viewport are a horizontal scrollbar and a
  299. '  vertical scrollbar.  On top of the viewport are buttons and comboboxes: a "Zoom-in"
  300. '  button, a "Zoom-out" button, a combobox for preview sizes, another for list of available
  301. '  pages, a "Previous page" button, a "Next page" button, a "Print"  button and a "Close"
  302. '  button. (3) a form for the page setup (margins).
  303. '  Explanation of some key points:
  304. '  1.  In a RTB, a single line may have text formatted with different fonts, and there
  305. '      may be graphics in between as well. To capture the original contents and settings,
  306. '      we first "selprint" the selected page to a hidden picturebox (Since RTB does not
  307. '      have a hDC, we cannot "bitblt", nor paintpicture").  We then "stretchblt" that
  308. '      picturebox to other pictureboxes according to the desired sizes of preview.
  309. '  2.  Since Selprint method does not allow a programmer to set the position of output on
  310. '      the printer, and that  and comboborinter, anh is
  311. ' ne may have text formatted with different fonts,t  and comboborinter, anh is
  312. ' ne may have text formatted with different fonts,t  and comboborinter, anh is
  313. ' ne may have text formatted with different fonts,t  and comboborinter, anh is0Sincehe py5prmattedka text ehas 2Nmview &/or for printing
  314. '  page(s) selective5G:eral
  315. '  pictureboxes.  Controls placed outside thBside thBsideplarent foontrols pthBsideplarent foof ouoa      may be graphallow a programmer to set the position of outpumphahlighted text and/or picture only, etc.
  316. ic          =ext asr for printing
  317. '  page(s) selectively. Tanting
  318. 'inting
  319. '  page(s) selectively.sr for praa.20t a5p(s) selective5G:erTrld14dv         we A1a    "eion of output on
  320. '   2r
  321.