''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' MACRO NAME: PRTSCR32.EBM (update of 16-bit PRINTSCR.EBM - using OLE Automation)
' WRITTEN BY: Attachmate Automation Support
'DATE WRITTEN: 2/29/96
' DESCRIPTION: This macro prints the host screen for the Active Session Object.
'
' Notes: You must set the FileName$ variable equal to the name of
' your Windows printer prior to running this macro.
'
' This macro will only run with EXTRA! 6.0 or greater.
'
' © Copyright 1989-1996. Attachmate Corporation. All Rights Reserved
'
' This macro is provided as an example only and may need
' to be modified to work in your environment. It is
' provided as is, without warranty or support from
' Attachmate Corporation.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Modified on 12/20/2001
'
' Added routine to obtain users settings from session file. Added option
' for landscape printing mode
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Declare Function GetPrivateProfileStringA Lib "kernel32" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Declare Sub InitVars()
Global inisect$ ' INI file section
Global ininame$ ' INI file name
Global username$
Global printername$
Global pageset$
Option Explicit
Sub Main
InitVars
' Dimension macro variables and objects
Dim rc%, row%, MaxColumns%, MaxRows%, filenum%
Dim Screenbuf$, linebuf$, FileName$
Dim System As Object
Dim Session as Object
' Get the main system object
Set System = CreateObject("EXTRA.System")
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Aborting macro playback."
Stop
End If
' Get the necessary Session Object
Set Session = System.ActiveSession
If (Session is Nothing) Then
Msgbox "Could not create the Session object. Aborting macro playback."
Stop
End If
' Determine the size of the Presentation Space
MaxRows% = Session.Screen.Rows()
MaxColumns% = Session.Screen.Cols()
' Initialize variables to hold screen information
Screenbuf$ = ""
linebuf$ = Space$ (MaxColumns%)
' Copy the Presentation space
For row% = 1 to MaxRows%
' Get a row of data from the host screen
linebuf$ = Session.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock)
' Store the line read into screenbuf$
screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10)
Next
' Get the next available file number
filenum% = FreeFile
FileName$ = printername$
Open FileName$ For Output as filenum%
If pageset$ = "Landscape" then
Print # filenum%, Chr(27); "&l1O"
End If
' Print Username at top of page
Print # filenum%, "Username: " + username$ + Chr$ (13) + Chr$ (10)
' Print the screen with a form feed
Print # filenum%, screenbuf$; Chr$ (12)
'Close printer
Close filenum%
End Sub
Sub InitVars
'*************************************************************
' Gather username, printer and page orientation from session
' file..
'*************************************************************
Dim INIdefs$, Buffer$
Dim x%, strngchk%, SpcPos%
inisect$="Session"
ininame$="h:\extra\tcphost.edp"
INIdefs$=""
x%=254 ' Space for the buffer
Buffer$=space(x%) ' Create the buffer
x% = GetPrivateProfileStringA(inisect$,"PsDocumentName",INIDefs$,Buffer$,x%,ininame$)
username$=Buffer$
INIdefs$=""
x%=254 ' Space for the buffer
Buffer$=space(x%) ' Create the buffer
x% = GetPrivateProfileStringA(inisect$,"PsPrinterName",INIDefs$,Buffer$,x%,ininame$)
'Determine if printer is local or network
strngchk% = InStr(1, Buffer$, "\\")
If strngchk% Then
SpcPos% = InStr(1, Buffer$, ",") ' Find comma.
If SpcPos% Then
printername$ = Left$(Buffer$, SpcPos% - 1) ' Get printer name.
End If
Else
printername$ = "LPT1"
End If
INIdefs$=""
x%=254 ' Space for the buffer
Buffer$=space(x%) ' Create the buffer
x% = GetPrivateProfileStringA(inisect$,"PsOrientation",INIDefs$,Buffer$,x%,ininame$)
pageset$=Buffer$
End Sub