FaxMan Jr
Visual Basic Source Code for Creating a Cover Page

Visual Basic Source Code for Creating a Cover Page

 

This sample is a VB 4.0 .FRM file which contains the code to write a simple coverpage.

 

VERSION 4.00

Begin VB.Form frmMain

Caption = "Form1" 

ClientHeight = 8430 

ClientLeft = 3225 

ClientTop = 2250 

ClientWidth = 6690 

Height = 8835 

Left = 3165 

LinkTopic = "Form1" 

ScaleHeight = 8430 

ScaleWidth = 6690 

Top = 1905 

Width = 6810 

End

Attribute VB_Name = "frmMain"

Attribute VB_Creatable = False

Attribute VB_Exposed = False

Option Explicit

 

Dim fhndl As Integer

 

Private Type FontObj

OpCode As Integer 

RecLen As Integer 

Name As String * 20 

Size As Integer 

Bold As Integer 

Italic As Integer 

Underline As Integer 

Color As Long 

End Type

 

Private Type TextObj

OpCode As Integer 

RecLen As Integer 

X1 As Integer 

Y1 As Integer 

X2 As Integer 

Y2 As Integer 

Color As Long 

Flags As Integer 

End Type

 

Private Type LineObj

OpCode As Integer 

RecLen As Integer 

X1 As Integer 

Y1 As Integer 

X2 As Integer 

Y2 As Integer 

Width As Integer 

Style As Integer 

Color As Long 

End Type

 

Private Type BitMapObj

OpCode As Integer 

RecLen As Integer 

X1 As Integer 

Y1 As Integer 

X2 As Integer 

Y2 As Integer 

End Type

 

Private Sub Form_Load()

 

Dim FileName As String, TextStr As String

Dim BitMapRec As BitMapObj 

Dim BitMapName As String 

 

fhndl = FreeFile 

Open "d:\faxman2\vbsample.pg" For Binary Access Write As fhndl 

 

  'Add a bitmap called cologo.fmf to the coverpage. The logo file

  'must reside in the FaxMan Jr. server directory along with the cover pg file

 

BitMapName = "cologo.fmf" + Chr(0) 

BitMapRec.OpCode = 1 

BitMapRec.RecLen = Len(BitMapRec) + Len(BitMapName) 

Put fhndl, , BitMapRec 

Put fhndl, , BitMapName 

 

DrawBox 6440, 3400, 11700, 4400 

DrawBox 480, 4720, 5900, 7500 

DrawBox 6440, 4720, 11700, 7500 

 

DrawBox 480, 7750, 11700, 12500 

DrawLine 480, 8500, 11700, 8500 

 

SetFont "Arial Black", 450, 1 

WriteText 600, 2400, 7800, 3000, "Sample FaxMan Jr. Cover Page" 

 

SetFont "Times New Roman", 900, 1 

WriteText 600, 3360, 2640, 4080, "FAX" 

 

SetFont "Times New Roman", 240, 0 

WriteText 7000, 3650, 10400, 4080, "Date:" 

WriteText 7000, 3970, 10080, 4280, "Number of pages including cover sheet:" 

WriteText 1000, 5500, 2500, 5900, "Name:" 

WriteText 1000, 6000, 2500, 6400, "Company:" 

WriteText 1000, 7000, 2500, 7400, "Fax phone:" 

 

WriteText 7000, 5500, 10000, 5900, "Name:" 

WriteText 7000, 6000, 10000, 6400, "Company:" 

WriteText 7000, 6500, 10000, 6900, "Phone:" 

WriteText 7000, 7000, 10000, 7400, "Fax phone:" 

 

WriteText 2050, 8050, 11600, 8500, "%u" 

WriteText 1000, 9000, 11600, 12400, "%o" 

 

SetFont "Times New Roman", 300, 1 

WriteText 7950, 3600, 11600, 4080, "%d" 

WriteText 10320, 3920, 11600, 4280, "%p" 

 

WriteText 750, 5000, 2500, 5400, "To:" 

WriteText 6750, 5000, 10000, 5400, "From:" 

 

WriteText 2050, 5450, 5800, 5900, "%r" 

WriteText 2050, 5950, 5800, 6400, "%y" 

WriteText 2050, 6950, 5800, 7400, "%f" 

 

WriteText 8050, 5450, 11600, 5900, "%s" 

WriteText 8050, 5950, 11600, 6400, "%m" 

WriteText 8050, 6450, 11600, 6900, "%h" 

WriteText 8050, 6950, 11600, 7400, "%x" 

 

WriteText 750, 8000, 2500, 8400, "Subject:" 

WriteText 750, 8700, 2500, 9100, "Comments:" 

 

Close fhndl 

 

End 

 

End Sub

 

 

 

Public Sub WriteText(X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer, TextStr As String)

 

Dim TextRec As TextObj 

 

TextRec.OpCode = 5 

TextRec.X1 = X1 

TextRec.Y1 = Y1 

TextRec.X2 = X2 

TextRec.Y2 = Y2 

TextStr = TextStr + Chr$(0) 

TextRec.RecLen = Len(TextRec) + Len(TextStr) 

Put fhndl, , TextRec 

Put fhndl, , TextStr 

 

End Sub

 

Public Sub SetFont(Name As String, Size As Integer, Bold As Integer)

 

Dim FontRec As FontObj 

 

FontRec.OpCode = 2 

FontRec.RecLen = Len(FontRec) 

 

FontRec.Name = Name + String$(20 - Len(Name), Chr$(0)) 

FontRec.Size = Size 

FontRec.Bold = Bold 

Put fhndl, , FontRec 

 

End Sub

 

Public Sub DrawLine(X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer)

 

Dim LineRec As LineObj 

 

LineRec.OpCode = 4 

LineRec.RecLen = Len(LineRec) 

 

LineRec.X1 = X1 

LineRec.Y1 = Y1 

LineRec.X2 = X2 

LineRec.Y2 = Y2 

LineRec.Color = 0 

LineRec.Width = 10 

Put fhndl, , LineRec 

 

End Sub

 

Public Sub DrawBox(X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer)

 

DrawLine X1, Y1, X2, Y1 

DrawLine X1, Y2, X2, Y2 

DrawLine X1, Y1, X1, Y2 

DrawLine X2, Y1, X2, Y2 

End Sub

 

 


© 2014 Data Techniques, Inc. All Rights Reserved.

Send comments on this topic.