' +---------------------------------------------------------------------+ ' | - P r i n t I t . B a s - | ' | | ' | Public Domain - FreeWare | ' | | ' | Compiled with FreeBASIC v0.17 | ' +---------------------------------------------------------------------+ ' +---------------------------------------------------------------------+ ' | - ABOUT THE AUTHOR - | ' +---------------------------------------------------------------------+ ' | | ' | Hello. My name is Don Smith and I am a thirty-year retired teacher | ' | of Math/History/Spanish residing in Orange County, California. I | ' | am also a former six-year Sergeant of Marines. Who-Rah! On certain | ' | forums I am known as MarineDon. My email is: smithdonb@earthlink.net| ' | | ' +---------------------------------------------------------------------+ ' | - COPYING AND DISTIBUTING - | ' +---------------------------------------------------------------------+ ' | Since this code is public domain and freeware, anyone may freely | ' | copy and distribute it. If you use the QuickBasic code in one of | ' | your own programs, you do not have to cite my name as the author, | ' | and you may even change its name. | ' +---------------------------------------------------------------------+ ' | | ' | This print program may be used by a QuickBasic program by using | ' | the SHELL command. | ' | | ' | Example: SHELL "PrintIt.Exe" + " " + "YourFile.Txt" | ' | | ' +---------------------------------------------------------------------+ #include "windows.bi" #include "win/commdlg.bi" Dim Shared As String ThrowAway Dim Shared As String printerName Dim Shared As String ComFile Dim Shared As String M() Dim Shared As Integer MeanWhile Dim Shared As Integer PrintDaFile Dim Shared As Integer PutIntoM ComFile = Command$ If ComFile = "" Then Dim Title As String Title = "PrintIt - Public Domain/FreeWare" WindowTitle Title 'Compile For Icon: fbc fblogo.rc PrintIt.Bas Screen 13 Color 15, 1 Cls Print Print Print Print " ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿" Print " ³ ³" Print " ³ You must include a file to print.³" Print " ³ ³" Print " ³ Example: PrintIt MyFile.Txt ³" Print " ³ ³" Print " ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵" Print " ³ ³" Print " ³ Public Domain FreeWare by ³" Print " ³ ³" Print " ³ ð Don Smith ð ³" Print " ³ ³" Print " ÆÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͵" Print " ³ ³" Print " ³Today's Date : 07/22/2007 ³" Print " ³ ³" Print " ³Don's Email:smithdonb@eartlink.net³" Print " ³ ³" Print " ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ" Sleep End End If Open ComFile For Input As #3 Do If Eof(3) Then Exit Do MeanWhile = MeanWhile + 1 Line Input #3, ThrowAway Loop Until Eof(3) Close #3 Redim M(MeanWhile) As String Open ComFile For Input As #2 For PutIntoM = 1 To MeanWhile Line Input #2, M(PutIntoM) Next Close #2 '============================================================ Function PrintHookProc( Byval hDlg As HWND, _ Byval uMsg As UINT, _ Byval wParam As WPARAM, _ Byval lParam As LPARAM ) As Integer Dim As Integer x,y,w,h Dim As RECT rc Select Case uMsg Case WM_INITDIALOG GetWindowRect( hDlg, @rc ) w = rc.right+1 h = rc.bottom+1 x = (GetSystemMetrics( SM_CXSCREEN ) / 2) - w / 2 y = (GetSystemMetrics( SM_CYSCREEN ) / 2) - h / 2 MoveWindow( hDlg, x, y, w, h, false ) End Select Return 0 End Function '============================================================ Function selectPrinter( ) As String Dim As PRINTDLG pd '============================================================ pd.flags = PD_ENABLEPRINTHOOK pd.lpfnPrintHook = cast(LPPRINTHOOKPROC,@PrintHookProc) '============================================================ pd.lStructSize = sizeof( PRINTDLG ) If PrintDlg( @pd ) = FALSE Then Exit Function End If Dim As DEVNAMES Ptr dn = GlobalLock( pd.hDevNames ) Function = *cast( Zstring Ptr, cast( Byte Ptr, dn ) + dn->wDeviceOffset ) GlobalUnlock( dn ) End Function printerName = selectPrinter( ) If( Open Lpt( "LPT:" + printerName + ",EMU=TTY", For Output, As #1 ) = 0 ) Then If printerName = "" Then End Elseif Len(printerName) > 0 Then For PrintDaFile = 1 To MeanWhile Print #1, M(PrintDaFile) Next Close #1 End End If End If