home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 September / Chip_2002-09_cd1.bin / zkuste / vbasic / Data / Utils / glm2demo.exe / %MAINDIR% / CommonDialog / print.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2002-06-10  |  18.9 KB  |  569 lines

  1. VERSION 5.00
  2. Begin VB.Form PrintDlgForm 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Print example"
  5.    ClientHeight    =   6825
  6.    ClientLeft      =   390
  7.    ClientTop       =   330
  8.    ClientWidth     =   6930
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   6825
  13.    ScaleWidth      =   6930
  14.    ShowInTaskbar   =   0   'False
  15.    Begin VB.Frame Frame7 
  16.       Caption         =   "Other Options"
  17.       BeginProperty Font 
  18.          Name            =   "MS Sans Serif"
  19.          Size            =   8.25
  20.          Charset         =   0
  21.          Weight          =   700
  22.          Underline       =   0   'False
  23.          Italic          =   0   'False
  24.          Strikethrough   =   0   'False
  25.       EndProperty
  26.       Height          =   1575
  27.       Left            =   120
  28.       TabIndex        =   36
  29.       Top             =   4560
  30.       Width           =   6735
  31.       Begin VB.CheckBox PrinterDefaultCheck 
  32.          Caption         =   "PrinterDefault"
  33.          Height          =   285
  34.          Left            =   4440
  35.          TabIndex        =   25
  36.          Top             =   270
  37.          Width           =   1605
  38.       End
  39.       Begin VB.TextBox MinPageText 
  40.          Height          =   285
  41.          Left            =   1320
  42.          TabIndex        =   29
  43.          Top             =   1200
  44.          Width           =   615
  45.       End
  46.       Begin VB.TextBox MaxPageText 
  47.          Height          =   285
  48.          Left            =   2640
  49.          TabIndex        =   30
  50.          Top             =   1200
  51.          Width           =   615
  52.       End
  53.       Begin VB.TextBox ToPageText 
  54.          Height          =   285
  55.          Left            =   2640
  56.          TabIndex        =   28
  57.          Top             =   720
  58.          Width           =   615
  59.       End
  60.       Begin VB.TextBox FromPageText 
  61.          Height          =   285
  62.          Left            =   1320
  63.          TabIndex        =   27
  64.          Top             =   720
  65.          Width           =   615
  66.       End
  67.       Begin VB.TextBox NumOfCopiesText 
  68.          Height          =   285
  69.          Left            =   5850
  70.          TabIndex        =   31
  71.          Top             =   1200
  72.          Width           =   735
  73.       End
  74.       Begin VB.CheckBox RaiseEventCheck 
  75.          Caption         =   "Raise Callback &Event"
  76.          Height          =   285
  77.          Left            =   4440
  78.          TabIndex        =   26
  79.          Top             =   720
  80.          Width           =   1875
  81.       End
  82.       Begin VB.TextBox PrintCaptionText 
  83.          Height          =   315
  84.          Left            =   1710
  85.          TabIndex        =   24
  86.          Text            =   "Custom Print"
  87.          Top             =   240
  88.          Width           =   2385
  89.       End
  90.       Begin VB.Label Label11 
  91.          AutoSize        =   -1  'True
  92.          Caption         =   "from:"
  93.          Height          =   195
  94.          Left            =   840
  95.          TabIndex        =   43
  96.          Top             =   1230
  97.          Width           =   345
  98.       End
  99.       Begin VB.Label Label5 
  100.          AutoSize        =   -1  'True
  101.          Caption         =   "from:"
  102.          Height          =   195
  103.          Left            =   840
  104.          TabIndex        =   42
  105.          Top             =   750
  106.          Width           =   345
  107.       End
  108.       Begin VB.Label Label9 
  109.          Alignment       =   1  'Right Justify
  110.          AutoSize        =   -1  'True
  111.          Caption         =   "Min"
  112.          Height          =   195
  113.          Index           =   1
  114.          Left            =   240
  115.          TabIndex        =   41
  116.          Top             =   1230
  117.          Width           =   255
  118.       End
  119.       Begin VB.Label Label10 
  120.          Alignment       =   1  'Right Justify
  121.          AutoSize        =   -1  'True
  122.          Caption         =   "Max to:"
  123.          Height          =   195
  124.          Index           =   1
  125.          Left            =   2040
  126.          TabIndex        =   40
  127.          Top             =   1230
  128.          Width           =   525
  129.       End
  130.       Begin VB.Label Label10 
  131.          Alignment       =   1  'Right Justify
  132.          AutoSize        =   -1  'True
  133.          Caption         =   "to:"
  134.          Height          =   195
  135.          Index           =   0
  136.          Left            =   2400
  137.          TabIndex        =   39
  138.          Top             =   750
  139.          Width           =   180
  140.       End
  141.       Begin VB.Label Label9 
  142.          Alignment       =   1  'Right Justify
  143.          AutoSize        =   -1  'True
  144.          Caption         =   "Pages"
  145.          Height          =   195
  146.          Index           =   0
  147.          Left            =   240
  148.          TabIndex        =   38
  149.          Top             =   750
  150.          Width           =   450
  151.       End
  152.       Begin VB.Label Label3 
  153.          AutoSize        =   -1  'True
  154.          Caption         =   "Number of Copies"
  155.          Height          =   195
  156.          Left            =   4440
  157.          TabIndex        =   37
  158.          Top             =   1230
  159.          Width           =   1260
  160.       End
  161.       Begin VB.Label Label4 
  162.          Caption         =   "Print Di&alog Caption"
  163.          Height          =   255
  164.          Left            =   240
  165.          TabIndex        =   23
  166.          Top             =   285
  167.          Width           =   1515
  168.       End
  169.    End
  170.    Begin VB.Frame Frame5 
  171.       Caption         =   "Help Options"
  172.       BeginProperty Font 
  173.          Name            =   "MS Sans Serif"
  174.          Size            =   8.25
  175.          Charset         =   0
  176.          Weight          =   700
  177.          Underline       =   0   'False
  178.          Italic          =   0   'False
  179.          Strikethrough   =   0   'False
  180.       EndProperty
  181.       Height          =   1455
  182.       Index           =   1
  183.       Left            =   120
  184.       TabIndex        =   35
  185.       Top             =   3060
  186.       Width           =   6735
  187.       Begin VB.OptionButton HelpContextOpt 
  188.          Caption         =   "Help Co&ntext"
  189.          Height          =   255
  190.          Left            =   180
  191.          TabIndex        =   17
  192.          Top             =   690
  193.          Value           =   -1  'True
  194.          Width           =   1245
  195.       End
  196.       Begin VB.TextBox HelpFileText 
  197.          Height          =   315
  198.          Left            =   1410
  199.          TabIndex        =   15
  200.          Top             =   210
  201.          Width           =   4005
  202.       End
  203.       Begin VB.OptionButton HelpKeyOpt 
  204.          Caption         =   "Help &Key"
  205.          Height          =   255
  206.          Left            =   180
  207.          TabIndex        =   20
  208.          Top             =   1080
  209.          Width           =   1245
  210.       End
  211.       Begin VB.TextBox HelpContextNumberText 
  212.          Height          =   315
  213.          Left            =   2880
  214.          TabIndex        =   19
  215.          Top             =   630
  216.          Width           =   1005
  217.       End
  218.       Begin VB.TextBox HelpKeyText 
  219.          Height          =   315
  220.          Left            =   2880
  221.          TabIndex        =   22
  222.          Top             =   1050
  223.          Width           =   1005
  224.       End
  225.       Begin VB.CommandButton Command1 
  226.          Caption         =   "&Browse..."
  227.          Height          =   375
  228.          Left            =   5520
  229.          TabIndex        =   16
  230.          Top             =   200
  231.          Width           =   1095
  232.       End
  233.       Begin VB.Label Label6 
  234.          Caption         =   "&Help File Name"
  235.          Height          =   255
  236.          Left            =   180
  237.          TabIndex        =   14
  238.          Top             =   270
  239.          Width           =   1155
  240.       End
  241.       Begin VB.Label Label7 
  242.          Caption         =   "Context Number"
  243.          Height          =   255
  244.          Left            =   1620
  245.          TabIndex        =   18
  246.          Top             =   690
  247.          Width           =   1155
  248.       End
  249.       Begin VB.Label Label8 
  250.          Caption         =   "Help Key Word"
  251.          Height          =   255
  252.          Left            =   1620
  253.          TabIndex        =   21
  254.          Top             =   1110
  255.          Width           =   1155
  256.       End
  257.    End
  258.    Begin VB.Frame Frame4 
  259.       Caption         =   "OK and Cancel Button Options"
  260.       BeginProperty Font 
  261.          Name            =   "MS Sans Serif"
  262.          Size            =   8.25
  263.          Charset         =   0
  264.          Weight          =   700
  265.          Underline       =   0   'False
  266.          Italic          =   0   'False
  267.          Strikethrough   =   0   'False
  268.       EndProperty
  269.       Height          =   1455
  270.       Left            =   120
  271.       TabIndex        =   34
  272.       Top             =   120
  273.       Width           =   4215
  274.       Begin VB.CheckBox CancelErrorCheck 
  275.          Caption         =   "&Raise Error On Cancel"
  276.          Height          =   285
  277.          Left            =   2160
  278.          TabIndex        =   1
  279.          Top             =   240
  280.          Width           =   1905
  281.       End
  282.       Begin VB.CheckBox HideCancelCheck 
  283.          Caption         =   "Hide Cancel B&utton"
  284.          Height          =   285
  285.          Left            =   120
  286.          TabIndex        =   0
  287.          Top             =   240
  288.          Width           =   1845
  289.       End
  290.       Begin VB.CheckBox CustomButtonCaptionCheck 
  291.          Caption         =   "Change &OK Button Caption"
  292.          Height          =   285
  293.          Left            =   120
  294.          TabIndex        =   2
  295.          Top             =   660
  296.          Width           =   2865
  297.       End
  298.       Begin VB.TextBox CustomButtonCaptionText 
  299.          Height          =   345
  300.          Left            =   3060
  301.          TabIndex        =   3
  302.          Text            =   "&Select"
  303.          Top             =   630
  304.          Width           =   945
  305.       End
  306.       Begin VB.TextBox CustomCancelCaptionText 
  307.          Height          =   345
  308.          Left            =   3060
  309.          TabIndex        =   5
  310.          Text            =   "E&xit"
  311.          Top             =   1050
  312.          Width           =   945
  313.       End
  314.       Begin VB.CheckBox CustomCancelCaptionCheck 
  315.          Caption         =   "Change &Cancel Button Caption"
  316.          Height          =   285
  317.          Left            =   120
  318.          TabIndex        =   4
  319.          Top             =   1080
  320.          Width           =   2865
  321.       End
  322.    End
  323.    Begin VB.Frame Frame3 
  324.       Caption         =   "Dialog Box Position"
  325.       BeginProperty Font 
  326.          Name            =   "MS Sans Serif"
  327.          Size            =   8.25
  328.          Charset         =   0
  329.          Weight          =   700
  330.          Underline       =   0   'False
  331.          Italic          =   0   'False
  332.          Strikethrough   =   0   'False
  333.       EndProperty
  334.       Height          =   1440
  335.       Left            =   120
  336.       TabIndex        =   33
  337.       Top             =   1600
  338.       Width           =   4215
  339.       Begin VB.CheckBox SetDlgPosCheck 
  340.          Caption         =   "Set &Dialog Position"
  341.          Height          =   285
  342.          Left            =   120
  343.          TabIndex        =   6
  344.          Top             =   240
  345.          Width           =   1845
  346.       End
  347.       Begin VB.CheckBox SetDlgPosToScreenCheck 
  348.          Caption         =   "Set Dialog &Position Relative To Screen"
  349.          Height          =   285
  350.          Left            =   360
  351.          TabIndex        =   7
  352.          Top             =   630
  353.          Width           =   3075
  354.       End
  355.       Begin VB.TextBox XPosText 
  356.          Height          =   345
  357.          Left            =   1380
  358.          TabIndex        =   9
  359.          Text            =   "0"
  360.          Top             =   990
  361.          Width           =   555
  362.       End
  363.       Begin VB.TextBox YPosText 
  364.          Height          =   345
  365.          Left            =   2880
  366.          TabIndex        =   11
  367.          Text            =   "0"
  368.          Top             =   990
  369.          Width           =   555
  370.       End
  371.       Begin VB.Label Label1 
  372.          Caption         =   "&X Position"
  373.          Height          =   225
  374.          Left            =   540
  375.          TabIndex        =   8
  376.          Top             =   1050
  377.          Width           =   765
  378.       End
  379.       Begin VB.Label Label2 
  380.          Caption         =   "&Y Position"
  381.          Height          =   225
  382.          Left            =   2040
  383.          TabIndex        =   10
  384.          Top             =   1050
  385.          Width           =   735
  386.       End
  387.    End
  388.    Begin VB.Frame Frame2 
  389.       Caption         =   "&Flags"
  390.       BeginProperty Font 
  391.          Name            =   "MS Sans Serif"
  392.          Size            =   8.25
  393.          Charset         =   0
  394.          Weight          =   700
  395.          Underline       =   0   'False
  396.          Italic          =   0   'False
  397.          Strikethrough   =   0   'False
  398.       EndProperty
  399.       Height          =   2940
  400.       Left            =   4440
  401.       TabIndex        =   12
  402.       Top             =   120
  403.       Width           =   2415
  404.       Begin VB.ListBox List1 
  405.          Height          =   2205
  406.          ItemData        =   "print.frx":0000
  407.          Left            =   120
  408.          List            =   "print.frx":0046
  409.          MultiSelect     =   1  'Simple
  410.          TabIndex        =   13
  411.          Top             =   240
  412.          Width           =   2175
  413.       End
  414.    End
  415.    Begin VB.CommandButton ShowPrintBut 
  416.       Caption         =   "&Show Dialog!"
  417.       BeginProperty Font 
  418.          Name            =   "MS Sans Serif"
  419.          Size            =   13.5
  420.          Charset         =   0
  421.          Weight          =   700
  422.          Underline       =   0   'False
  423.          Italic          =   0   'False
  424.          Strikethrough   =   0   'False
  425.       EndProperty
  426.       Height          =   525
  427.       Left            =   4560
  428.       TabIndex        =   32
  429.       Top             =   6240
  430.       Width           =   2325
  431.    End
  432. Attribute VB_Name = "PrintDlgForm"
  433. Attribute VB_GlobalNameSpace = False
  434. Attribute VB_Creatable = False
  435. Attribute VB_PredeclaredId = True
  436. Attribute VB_Exposed = False
  437. Option Explicit
  438. Dim WithEvents dwCmdDialog As dwPrint
  439. Attribute dwCmdDialog.VB_VarHelpID = -1
  440. Private Sub command1_Click()
  441. Dim dwCmdDialog As dwFileOpenSave
  442. Dim lres As Long
  443. Dim lstr As String
  444.     Set dwCmdDialog = New dwFileOpenSave
  445.     dwCmdDialog.DialogTitle = "Select Help File"
  446.     dwCmdDialog.Filter = "Help (*.hlp)|*.hlp|All Files (*.*)|*.*"
  447.     dwCmdDialog.DlgWindowOwner = Me.hWnd
  448.     dwCmdDialog.SetDialogPosition = True
  449.     dwCmdDialog.PosX = 50
  450.     dwCmdDialog.PosY = 50
  451.     dwCmdDialog.CustomOkButtonCaption = True
  452.     dwCmdDialog.OkButtonCaption = "Select"
  453.     dwCmdDialog.Flags = glmcdOFNEnableHook Or glmcdOFNLongNames Or glmcdOFNFileMustexist Or glmcdOFNNoChangeDir Or glmcdOFNHideReadOnly
  454.     If WindowsVersion <> 35 Then
  455.         dwCmdDialog.Flags = dwCmdDialog.Flags Or glmcdOFNExplorer
  456.     End If
  457.     lres = dwCmdDialog.ShowOpen
  458.     If lres = 1 Then
  459.         HelpFileText.Text = dwCmdDialog.filename
  460.     End If
  461.     Set dwCmdDialog = Nothing
  462. End Sub
  463. Private Sub Form_Load()
  464.     If SetDlgPosCheck.Value Then
  465.         SetDlgPosToScreenCheck.Enabled = True
  466.         XPosText.Enabled = True
  467.         YPosText.Enabled = True
  468.     Else
  469.         SetDlgPosToScreenCheck.Enabled = False
  470.         XPosText.Enabled = False
  471.         YPosText.Enabled = False
  472.     End If
  473.     ' Initialize list box
  474.     List1.Selected(4) = True    ' collate
  475.     List1.Selected(11) = True   ' show help button
  476.     List1.Selected(12) = True   ' enable hook
  477. End Sub
  478. Private Sub HelpContextOpt_Click()
  479.     HelpContextNumberText.Enabled = True
  480.     HelpKeyText.Enabled = False
  481.     HelpKeyText.Text = ""
  482. End Sub
  483. Private Sub HelpKeyOpt_Click()
  484.     HelpKeyText.Enabled = True
  485.     HelpContextNumberText.Enabled = False
  486.     HelpContextNumberText.Text = ""
  487. End Sub
  488. Private Sub OpenSaveCaptionText_Change()
  489. End Sub
  490. Private Sub SetDlgPosCheck_Click()
  491.     If SetDlgPosCheck.Value Then
  492.         SetDlgPosToScreenCheck.Enabled = True
  493.         XPosText.Enabled = True
  494.         YPosText.Enabled = True
  495.     Else
  496.         SetDlgPosToScreenCheck.Enabled = False
  497.         XPosText.Enabled = False
  498.         YPosText.Enabled = False
  499.     End If
  500. End Sub
  501. Private Function GetPrintFlags() As Long
  502. Dim lcount As Long, lindex As Long
  503. Dim flagvalue As Long
  504.     lindex = List1.ListCount
  505.     For lcount = 0 To lindex - 1 Step 1
  506.         If List1.Selected(lcount) Then
  507.             flagvalue = flagvalue + 2 ^ lcount
  508.         End If
  509.     Next
  510.     GetPrintFlags = flagvalue
  511. End Function
  512. Private Sub ShowPrintBut_Click()
  513. Dim lres As Long
  514. Dim lstr As String
  515.     On Error GoTo printererror
  516.     Set dwCmdDialog = New dwPrint
  517.     dwCmdDialog.DialogTitle = PrintCaptionText.Text
  518.     dwCmdDialog.DlgWindowOwner = Me.hWnd
  519.     dwCmdDialog.HideCancel = HideCancelCheck.Value
  520.     dwCmdDialog.SetDialogPosition = SetDlgPosCheck.Value
  521.     dwCmdDialog.SetDialogRelativeToScreen = SetDlgPosToScreenCheck.Value
  522.     dwCmdDialog.PosX = Val(XPosText.Text)
  523.     dwCmdDialog.PosY = Val(YPosText.Text)
  524.     dwCmdDialog.CustomOkButtonCaption = CustomButtonCaptionCheck.Value
  525.     dwCmdDialog.OkButtonCaption = CustomButtonCaptionText.Text
  526.     dwCmdDialog.CustomCancelButtonCaption = CustomCancelCaptionCheck.Value
  527.     dwCmdDialog.CancelButtonCaption = CustomCancelCaptionText.Text
  528.     dwCmdDialog.Flags = GetPrintFlags()
  529.     dwCmdDialog.PrinterDefault = PrinterDefaultCheck.Value
  530.     dwCmdDialog.RaiseCallbackEvent = RaiseEventCheck.Value
  531.     dwCmdDialog.CancelError = CancelErrorCheck.Value
  532.     dwCmdDialog.HelpFile = Trim$(HelpFileText.Text)
  533.     If dwCmdDialog.HelpFile <> "" Then
  534.         If HelpContextOpt.Value Then
  535.             dwCmdDialog.HelpCommand = glmcdHCContext
  536.             dwCmdDialog.HelpContext = Val(HelpContextNumberText.Text)
  537.         Else
  538.             dwCmdDialog.HelpCommand = glmcdHCKey
  539.             dwCmdDialog.HelpKey = HelpKeyText.Text
  540.         End If
  541.     End If
  542.     If Trim$(FromPageText.Text) <> "" Then
  543.         dwCmdDialog.FromPage = Val(FromPageText.Text)
  544.     End If
  545.     If Trim$(ToPageText.Text) <> "" Then
  546.         dwCmdDialog.ToPage = Val(ToPageText.Text)
  547.     End If
  548.     If Trim$(MinPageText.Text) <> "" Then
  549.         dwCmdDialog.Min = Val(MinPageText.Text)
  550.     End If
  551.     If Trim$(MaxPageText.Text) <> "" Then
  552.         dwCmdDialog.Max = Val(MaxPageText.Text)
  553.     End If
  554.     If Trim$(NumOfCopiesText.Text) <> "" Then
  555.         dwCmdDialog.Copies = Val(NumOfCopiesText.Text)
  556.     End If
  557.     lres = dwCmdDialog.ShowPrinter
  558.     If lres = 1 Then
  559.         FromPageText.Text = dwCmdDialog.FromPage
  560.         ToPageText.Text = dwCmdDialog.ToPage
  561.         NumOfCopiesText.Text = dwCmdDialog.Copies
  562.     End If
  563.     Set dwCmdDialog = Nothing
  564.     Exit Sub
  565. printererror:
  566. Debug.Print "Error occurred " & Err.Number & ", " & Err.Description
  567.     Set dwCmdDialog = Nothing
  568. End Sub
  569.