home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
update
/
crescent
/
htprn
/
tsthtprn.frm
< prev
next >
Wrap
Text File
|
1995-01-24
|
10KB
|
264 lines
VERSION 2.00
Begin Form Form1
Caption = "Form1"
ClientHeight = 4815
ClientLeft = 1410
ClientTop = 1890
ClientWidth = 9585
Height = 5220
Left = 1350
LinkTopic = "Form1"
ScaleHeight = 321
ScaleMode = 3 'Pixel
ScaleWidth = 639
Top = 1545
Width = 9705
Begin CommandButton Command3
Caption = "Quit"
Height = 360
Left = 6660
TabIndex = 7
Top = 3960
Width = 1368
End
Begin CommandButton Command2
Caption = "Print All"
Height = 360
Left = 6615
TabIndex = 6
Top = 2700
Width = 1368
End
Begin CommandButton Command1
Caption = "Preview"
Height = 360
Left = 6615
TabIndex = 5
Top = 1500
Width = 1368
End
Begin csHyperText csHyperText1
BorderStyle = 1 'Fixed Single
FontBold = 0 'False
FontItalic = 0 'False
FontName = "Arial"
FontSize = 9.75
FontStrikethru = 0 'False
FontUnderline = 0 'False
HeadingColor = &H00800000&
HeadingSize = 14
Height = 4335
Left = 150
TabIndex = 0
Text = ""
Top = 105
Width = 6120
WordWrap = -1 'True
End
Begin Label Label5
BackStyle = 0 'Transparent
Caption = "Use Print All when you only want to print all pages without an intervening print preview."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 1140
Left = 6600
TabIndex = 3
Top = 3195
Width = 2685
End
Begin Label Label4
BackStyle = 0 'Transparent
Caption = "Preview allows your users to View separate pages of text, and print selectively also."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 1140
Left = 6570
TabIndex = 8
Top = 1935
Width = 2685
End
Begin Label Label3
BackStyle = 0 'Transparent
Caption = "You can allow your users to Print, or Print Preivew it."
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 810
Left = 6570
TabIndex = 4
Top = 915
Width = 2595
End
Begin Label Label2
BackStyle = 0 'Transparent
Caption = "On the left is your Crescent Software HyperText Control with its text"
FontBold = 0 'False
FontItalic = 0 'False
FontName = "MS Sans Serif"
FontSize = 8.25
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 780
Left = 6585
TabIndex = 2
Top = 420
Width = 2790
End
Begin Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "This is your application"
Height = 195
Left = 6570
TabIndex = 1
Top = 150
Width = 1980
End
End
Option Explicit
Declare Function WritePrivateProfileString% Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName$, ByVal lpString$, ByVal lplFileName$)
Dim sText As String
Sub Command1_Click ()
Dim sIniFile As String
' ----- Give a suitable name for an INI file to hold parameters
sIniFile = App.Path & "\TSTHTPRN.INI"
' ----- Provide Print Preview - See the comments in CreateTextFiles for explanation
CreateTextFiles sIniFile, True ' True indicates Preview is ON
' ----- And shell to CSHTPRN.EXE
PrintHyperText sIniFile
End Sub
Sub Command2_Click ()
Dim sIniFile As String
' ----- Give a suitable name for an INI file to hold parameters
sIniFile = App.Path & "\TSTHTPRN.INI"
' ----- Provide Print - See the comments in CreateTextFiles for explanation
CreateTextFiles sIniFile, False ' False indicates Preview is OFF
' ----- And shell to CSHTPRN.EXE
PrintHyperText sIniFile
End Sub
Sub Command3_Click ()
Unload Me
End
End Sub
Sub CreateTextFiles (sIniFile As String, fPreview As Integer)
' ----- First dump the HyperText Control's text into a text file - Any valid name is ok
Open App.Path & "\TSTHTPRN.TXT" For Output As #1
Print #1, sText
Close #1
' ----- Now make calls to Windows API function to write to an INI file.
' ----- You need to use a wrapper by sending INI file name, Section, Keyword and value
' ----- This two lines below are the only MANDATORY lines you need to use
' ----- Tell it what file to find the text in
WriteProfileString sIniFile, "HyperText", "TextFile", App.Path & "\TSTHTPRN.TXT"
' ----- Tell it whether to preview (true = -1) or print directly (false = 0)
WriteProfileString sIniFile, "Action", "Preview", Trim$(Str$(fPreview))
' ----- If you wish, you need not use any of the following lines, the defaults will be
' ----- used. These lines are provided for you to customize the appearance of the preview/
' ----- printed page
' ----- If you wish to, set up the page margins, else, all will default to 1" if not found
WriteProfileString sIniFile, "PageSetup", "TopMargin", "1"
WriteProfileString sIniFile, "PageSetup", "BottomMargin", "1"
WriteProfileString sIniFile, "PageSetup", "LeftMargin", "1"
WriteProfileString sIniFile, "PageSetup", "RightMargin", "1"
' ----- Now determine what fonts you need to use to print out
' ----- Header Font Name = Default to "Arial" if not found
WriteProfileString sIniFile, "Fonts", "HeaderFontName", "Arial"
' ----- Header Font Size = Default to 14 if not found
WriteProfileString sIniFile, "Fonts", "HeaderFontSize", "14"
' ----- Text Font Name = Default to "Arial" if not found
WriteProfileString sIniFile, "Fonts", "TextFontName", "Arial"
' ----- Text font Size = Default to 10 if not found
WriteProfileString sIniFile, "Fonts", "TextFontSize", "10"
' ----- Determine what color to use in printing header and text, can be overridden by Color settings
' ----- Color for header = Default Dark Blue if not found
WriteProfileString sIniFile, "Color", "Header", "C00000"
' ----- Color for text = Default Black if not found
WriteProfileString sIniFile, "Color", "Text", "00000"
' ----- You can specify lines to print as Headers and footers. There are two lines
' ----- of Header provided and one for footer. You can embed variables in these lines
' ----- as follows:
' ----- To Get this Use This
' ----- Page 1 Page @#
' ----- Page 1 of 3 Page @# of @N
' ----- System Date @D
' ----- System Time @T
' ----- Any other text Any other Text
' -----
' ----- Header line 1 = Defaults to "HyperText Printer" if not found
WriteProfileString sIniFile, "Header", "Line1", "This is My Header Line 1"
' ----- Header Line 2 = Defaults to null string if not found
WriteProfileString sIniFile, "Header", "Line2", "and my header line two"
' ----- Offset of Header from end of page = Default to 0.5" if not found
WriteProfileString sIniFile, "Header", "Offset", "0.5"
' ----- Footer line 1 = Defaults to Page Number if not found
WriteProfileString sIniFile, "Footer", "Line1", "Page @#"
' ----- Offset of Footer from end of page = Default to 0.5" if not found
WriteProfileString sIniFile, "Header", "Offset", "0.5"
End Sub
Sub Form_Load ()
' ----- Centers the form
Me.Move ((Screen.Width - Me.Width) / 2), ((Screen.Height - Me.Height) / 2)
Open App.Path & "\TST.TXT" For Input As #1
sText = Input$(LOF(1), #1)
Close #1
'sText = "This is a test \Pprogram\p for \JTesting\j the HyperText Utility created by Graphic Solutions"
csHyperText1.Text = sText
End Sub
Sub PrintHyperText (sIniFile As String)
Dim x%
x% = Shell(App.Path & "\CSHTPRUN.EXE " & sIniFile, 1)
End Sub
Sub WriteProfileString (sIniFile As String, sSection As String, sKeyWord As String, sValue As String)
Dim x%
x% = WritePrivateProfileString(sSection, sKeyWord, sValue, sIniFile)
End Sub