@gnozal
Found this library very useful today.
Here is a pseudo LPRINT Requester procedure. Maybe you can add this
to this useful library.
Quote:
Edited Dec 18 2004
Note: gnozal has updated his library with his own LPRINT_Requester. Thanks gnozal!
This code in this message has been revised so it remains compatible with the library.
Code:
; LPrint_Requester - TerryHough Dec 16, 2004
;
; Requires the PureLPRINT Library from gnozal
; See PB Forum topic http://jconserv.net/purebasic/viewtopic.php?t=12537
;
Procedure.s LPRINT_RequesterM(ParentWindow)
SelectWindow = OpenWindow(#PB_Any,0,0,400,200,#PB_Window_WindowCentered,"LPrint Selecter",ParentWindow)
If SelectWindow
CreateGadgetList(WindowID())
LI = ListIconGadget(#PB_Any,10,10,380,150,"Installed Printers (default printer is highlighted)",360,#PB_ListIcon_CheckBoxes )
TG = TextGadget(#PB_Any,20,172,350,30,"Click the check box beside the desired printer in the list above.",#PB_Text_Center)
Work$ = LPRINT_GetInstalledPrinters()
While Work$
Prt$ = StringField(Work$,1,";")
AddGadgetItem(LI,-1,Prt$)
Work$ = RemoveString(Work$,Prt$)
If Mid(Work$,1,1) = ";"
Work$ = Mid(Work$,2,Len(Work$))
EndIf
Wend
SelectedPrinter.s = LPRINT_GetDefaultPrinter()
For I= 0 To CountGadgetItems(LI) -1
If GetGadgetItemText(LI,I,0) = SelectedPrinter
SetGadgetItemState(LI,I,#PB_ListIcon_Selected)
ActivateGadget(LI)
Break
EndIf
Next
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadgetID()
Case Li ; Chckbox clicked
SetGadgetItemState(LI,I, 0)
While WindowEvent() : Wend
Break
EndSelect
EndSelect
Until EventID = #PB_EventCloseWindow
For i= 0 To CountGadgetItems(LI) -1
If GetGadgetItemState(LI,I) = #PB_ListIcon_Checked
SelectedPrinter = GetGadgetItemText(LI,I,0)
Break
EndIf
Next
SetGadgetText(TG,"Attmpting to open the " + SelectedPrinter + " printer.")
Delay(1000)
If LPRINT_OpenPrinter(SelectedPrinter)
; MessageRequester("DEbug","Opened " + SelectedPrinter,#MB_ICONINFOrMATION)
CloseWindow(SelectWindow)
ProcedureReturn SelectedPrinter
Else
MessageRequester("ERROR - LPRINT", "Printer " + SelectedPrinter + " not found", #MB_ICONERROR)
CloseWindow(SelectWindow)
ProcedureReturn ""
EndIf
Else
MessageRequester("ERROR - LPRINT", "LPRINT Selection could not be started.", #MB_ICONERROR)
EndIf
EndProcedure
;- Example of usage <-----------------------------------------------------------------
#Window_Main = 100
If OpenWindow(#Window_Main,0,0,500,500,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"LPrint Job")
CreateGadgetList(WindowID())
EditorGadget(#PB_Any,10,10,480,480)
While WindowEvent(): Wend
; Use the LPRINT_Requester procedure passing the WindowID of the calling window ----
; The procedure returns the name of the selected printer in a string. If the ----
; procedure fails to open the selected printer, it returns a null string. ----
MyPrinter.s = LPRINT_RequesterM(WindowID())
If MyPrinter
If LPRINT_StartDoc("MyJob")
; Print here as desired --------------------------------------------------------
; LPRINT_Print(Chr(27) + "E") ; PCL reset for HP Printers
; LPRINT_Print("Line 1")
; LPRINT_PrintN("Same Line")
; LPRINT_PrintN("Line 2")
; LPRINT_PrintN("")
; LPRINT_PrintN("Line 4")
; LPRINT_NewPage() ; Form feed
; LPRINT_Print("Line 1 (Page 2)")
LPRINT_EndDoc()
; End of printing --------------------------------------------------------------
Else
MessageRequester("ERROR - LPRINT", "Could not start job", #MB_ICONERROR)
EndIf
LPRINT_ClosePrinter()
EndIf
Else
MessageRequester("ERROR - LPRINT", "Could not open the main window.", #MB_ICONERROR)
EndIf
Repeat
ev=WaitWindowEvent()
Until ev=#PB_EventCloseWindow
End
I found this very handy to use with a laser printer and PCL language
files.
Need a way to send PCL files in excess of 64Kb such as font files, etc.
Any ideas would be appreciated.
Thanks,
Terry