PrinterLib 1.10
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: PrinterLib 1.10
SetPrinter_() sounds interesting though:
#PRINTER_CONTROL_PURGE: Delete all print jobs in the printer.
Of interest: FlushPrinter()
Another possibility would be to send printer-language instructions to the printer (PJL)
HP PJL
It seems HP have a solution for everything, including 'Personality Errors'......
#PRINTER_CONTROL_PURGE: Delete all print jobs in the printer.
Of interest: FlushPrinter()
Another possibility would be to send printer-language instructions to the printer (PJL)
HP PJL
It seems HP have a solution for everything, including 'Personality Errors'......
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: PrinterLib 1.10
Hello again yrreti, and thank you for the update. Nothing beats a QED confirmation.yrreti wrote:The code does work just before and when the printer just starts to become active (motors running). So I thought it worked. But once the printer starts printing, it doesn't.
Hi IdeasVacuum. Tested SetPrinter(...PRINTER_CONTROL_PURGE), and it yields the same results. FlushPrinter() is not natively available in PureBasic, and I can't seem to find any information on its import declarations. But from the MSDN description, it appears to be a write function to unclog the printer's memory, and not to delete it.IdeasVacuum wrote:SetPrinter_() sounds interesting though:
#PRINTER_CONTROL_PURGE: Delete all print jobs in the printer.
HP's PJL seems promising, although proprietary and not system-based.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
Re: PrinterLib 1.10
The help file (.chm) from the archive found at http://www.purebasicpower.de looks empty. Does someone have a working copy?
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: PrinterLib 1.10
It's tiny, but not empty: Printer_Lib.chm
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: PrinterLib 1.10
After download a .chm file from internet you need to set up special security
Without that the file seem to be empty.
Right clic on it and select property and then clic unblock
Look solution here
http://stackoverflow.com/questions/1143 ... s-canceled
Without that the file seem to be empty.
Right clic on it and select property and then clic unblock
Look solution here
http://stackoverflow.com/questions/1143 ... s-canceled
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: PrinterLib 1.10
Good tip about unblocking .chm files on Windows (7 and up). Note, that problem is usually only to do with the file being on a network drive.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: PrinterLib 1.10
Ahhh ok got it... Forgot to check Windows permissions. Guess if you copy to a FAT32 drive it would work too... Thanks for highlighting...
- DeanH
- Enthusiast
- Posts: 224
- Joined: Wed May 07, 2008 4:57 am
- Location: Adelaide, South Australia
- Contact:
Re: PrinterLib 1.10
Hi. I am using PrinterLib 1.10 with PureBasic 5.50 and have discovered the ipprint_PrintDlg function crashes at the GlobalSize_( statement. Windows 7. hGmem1 has a value from its previous GlobalAlloc but GlobalSize_( returns 0. If I recompile using PureBasic 5.31, it works fine. GlobalSize_ returns the size of the memory buffer.
Does anyone know of a solution?
The source code for this function is below.
Thanks.
__________________________________________________
Code tags added
24.08.2016
RSBasic
Does anyone know of a solution?
The source code for this function is below.
Thanks.
Code: Select all
Procedure.l ipprint_PrintDlg(Window.i=0,PrinterName$="",Option1$="",Option2$="")
Protected hwnd,res,Buffersize,hGmem1,hGmem2,*DevBuffer,*DevNames,*PrinterParameters.DEVMODE,*PrinterNames.DEVNAMES
If IsWindow(Window)
hwnd=WindowID(Window)
Else
hwnd=0
EndIf
If PrinterName$=""
PrintLib_PN=ipprint_GetDefaultPrinter()
Else
PrintLib_PN=PrinterName$
EndIf
If PrintLib_PH<>0
ClosePrinter_(PrintLib_PH)
PrintLib_PH=0
EndIf
res=OpenPrinter_(PrintLib_PN,@PrintLib_PH,0)
If res
Buffersize=DocumentProperties_(0,PrintLib_PH,PrintLib_PN,0,0,0)
If Buffersize=<0
ProcedureReturn 0
EndIf
hGmem1 = GlobalAlloc_(#GMEM_MOVEABLE|#GMEM_ZEROINIT, Buffersize)
hGmem2 = GlobalAlloc_(#GMEM_MOVEABLE|#GMEM_ZEROINIT, 1024+SizeOf(DEVNAMES))
;Debug "GlobalSize_(hGmem1)="+Str(GlobalSize_(hGmem1))
;Debug "GlobalSize_(hGmem2)="+Str(GlobalSize_(hGmem2))
*DevBuffer=GlobalLock_(hGmem1);AllocateMemory(Buffersize)
*DevNames=GlobalLock_(hGmem2);AllocateMemory(1024+SizeOf(DEVNAMES))
GlobalUnlock_(hGmem1)
GlobalUnlock_(hGmem2)
DocumentProperties_(0,PrintLib_PH,@PrintLib_PN,*DevBuffer,0,#DM_OUT_BUFFER)
*PrinterParameters=*DevBuffer
*PrinterNames=*DevNames
ipprint_SetDEVMODE(Option1$,*PrinterParameters)
;PrintLibDLG.PRINTDLG
ipprint_SetPRINTDLG(Option2$,PrintLibDLG)
PrintLibDLG\lStructSize=SizeOf(PRINTDLG)
PrintLibDLG\hWndOwner=hwnd
PrintLibDLG\hDevMode=hGmem1
PrintLibDLG\hDevNames=hGmem2
PrintLibDLG\Flags|$40000
If PrintLibDLG\nCopies=0
PrintLibDLG\nCopies=1
EndIf
If PrintLibDLG\nFromPage=0
PrintLibDLG\nFromPage=1
EndIf
If PrintLibDLG\nToPage=0
PrintLibDLG\nToPage=1
EndIf
If PrintLibDLG\nMinPage=0
PrintLibDLG\nMinPage=1
EndIf
If PrintLibDLG\nMaxPage=0
PrintLibDLG\nMaxPage=1
EndIf
res=PrintDlg_(PrintLibDLG)
If res<>0
;Debug "PrintDlg_ success res="+Str(res)
If *PrinterNames\wDeviceOffset<>0
PrintLib_PN=PeekS(*PrinterNames + *PrinterNames\wDeviceOffset)
;PRNNAME$=PrintLib_PN
;Debug "Buffersize="+Str(Buffersize)
;Debug "SizeOf(DEVMODE)="+Str(SizeOf(DEVMODE))
;Debug "dmSize="+Str(*PrinterParameters\dmSize)
;Debug "dmDriverExtra="+Str(*PrinterParameters\dmDriverExtra)
;Debug "GlobalSize_(hGmem1)="+Str(GlobalSize_(hGmem1))
;Debug "GlobalSize_(hGmem2)="+Str(GlobalSize_(hGmem2))
;copy devmode structure to internal buffer
*PrintLibDEVMODESize=GlobalSize_(hGmem1) ;<=== CRASHES HERE
*PrintLibDEVMODE=AllocateMemory(*PrintLibDEVMODESize)
CopyMemory(*DevBuffer,*PrintLibDEVMODE,*PrintLibDEVMODESize)
; open the printer and return it´s DC
res=ipprint_OpenPrinter(PrintLib_PN,"",0)
EndIf
EndIf
GlobalFree_(hGmem1)
GlobalFree_(hGmem2)
EndIf
ProcedureReturn res
EndProcedure
Code tags added
24.08.2016
RSBasic
- DeanH
- Enthusiast
- Posts: 224
- Joined: Wed May 07, 2008 4:57 am
- Location: Adelaide, South Australia
- Contact:
Re: PrinterLib 1.10
Further to the above ... I suspect is it Unicode related. I tried recompiling using PB 5.31 in Unicode mode and it crashed at the same place. I will try to dig into that but if anyone has an easy solution, it would be greatly appreciated.
Re: PrinterLib 1.10
Using PrintLib in PureBasic 5.60 (and some earlier versions) no longer works because PRINTDEV has no structure predefined.
Is there a newer version of PrintLib?
Or, can someone please create the structure of PRINTDEV, that we can see in C++ format at https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Thanks!
Is there a newer version of PrintLib?
Or, can someone please create the structure of PRINTDEV, that we can see in C++ format at https://msdn.microsoft.com/en-us/librar ... s.85).aspx
Code: Select all
typedef struct _devicemode {
TCHAR dmDeviceName[CCHDEVICENAME];
WORD dmSpecVersion;
WORD dmDriverVersion;
WORD dmSize;
WORD dmDriverExtra;
DWORD dmFields;
union {
struct {
short dmOrientation;
short dmPaperSize;
short dmPaperLength;
short dmPaperWidth;
short dmScale;
short dmCopies;
short dmDefaultSource;
short dmPrintQuality;
};
struct {
POINTL dmPosition;
DWORD dmDisplayOrientation;
DWORD dmDisplayFixedOutput;
};
};
short dmColor;
short dmDuplex;
short dmYResolution;
short dmTTOption;
short dmCollate;
TCHAR dmFormName[CCHFORMNAME];
WORD dmLogPixels;
DWORD dmBitsPerPel;
DWORD dmPelsWidth;
DWORD dmPelsHeight;
union {
DWORD dmDisplayFlags;
DWORD dmNup;
};
DWORD dmDisplayFrequency;
#if (WINVER >= 0x0400)
DWORD dmICMMethod;
DWORD dmICMIntent;
DWORD dmMediaType;
DWORD dmDitherType;
DWORD dmReserved1;
DWORD dmReserved2;
#if (WINVER >= 0x0500) || (_WIN32_WINNT >= 0x0400)
DWORD dmPanningWidth;
DWORD dmPanningHeight;
#endif
#endif
} DEVMODE, *PDEVMODE, *LPDEVMODE;
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
Re: PrinterLib 1.10
w/PB It's named DEVMODE
Code: Select all
Structure DEVMODE
dmDeviceName.c[32]
dmSpecVersion.w
dmDriverVersion.w
dmSize.w
dmDriverExtra.w
dmFields.l
StructureUnion
Printer.DEVMODE_PRINTER
Display.DEVMODE_DISPLAY
EndStructureUnion
dmColor.w
dmDuplex.w
dmYResolution.w
dmTTOption.w
dmCollate.w
dmFormName.c[32]
dmLogPixels.w
dmBitsPerPel.l
dmPelsWidth.l
dmPelsHeight.l
StructureUnion
dmDisplayFlags.l
dmNup.l
EndStructureUnion
dmDisplayFrequency.l
dmICMMethod.l
dmICMIntent.l
dmMediaType.l
dmDitherType.l
dmReserved1.l
dmReserved2.l
dmPanningWidth.l
dmPanningHeight.l
EndStructure
Structure DEVMODE_PRINTER
dmOrientation.w
dmPaperSize.w
dmPaperLength.w
dmPaperWidth.w
dmScale.w
dmCopies.w
dmDefaultSource.w
dmPrintQuality.w
EndStructure
Structure DEVMODE_DISPLAY
dmPosition.POINT
dmDisplayOrientation.l
dmDisplayFixedOutput.l
EndStructure
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Re: PrinterLib 1.10
Thank you very much Thunder93!
Now I'll try to implement it in my code...
Now I'll try to implement it in my code...
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
Re: PrinterLib 1.10
It is strange. I implemented your Structure DEVMODE, the compiler then says:Thunder93 wrote:
w/PB It's named DEVMODE
Without your structure, the compiler says:Structure already declared: DEVMODE (in a resident file)
What's missing here? Is DEVMODE included in PureBasic? Is the internal structure correct?Structure field not found: dmOrientation
The code that gives the problem is here (under CASE "ORIENTATION"): (code is from PureLib, with the exception that the procedurenames are always beginning with a 'z' in my final codes)
Code: Select all
Procedure zPrintLibSetDEVMODE(Option$,*PrinterParameters.DEVMODE)
Protected Flags,cnt,i,part$,opt$,value
cnt=CountString(Option$,",")
For i=0 To cnt
part$=StringField(Option$,i+1,",")
opt$=StringField(part$,1,"=")
value=Val(StringField(part$,2,"="))
Select UCase(opt$)
Case "ORIENTATION"
*PrinterParameters\dmFields|#DM_ORIENTATION
*PrinterParameters\dmOrientation=value
Case "PAPERSIZE"
*PrinterParameters\dmFields|#DM_PAPERSIZE
*PrinterParameters\dmPapersize=value
Case "PAPERLENGTH"
*PrinterParameters\dmFields|#DM_PAPERLENGTH
*PrinterParameters\dmPaperlength=value
Case "PAPERWIDTH"
*PrinterParameters\dmFields|#DM_PAPERWIDTH
*PrinterParameters\dmPaperwidth=value
Case "SCALE"
*PrinterParameters\dmFields|#DM_SCALE
*PrinterParameters\dmScale=value
Case "COPIES"
*PrinterParameters\dmFields|#DM_COPIES
*PrinterParameters\dmCopies=value
Case "DEFAULTSOURCE"
*PrinterParameters\dmFields|#DM_DEFAULTSOURCE
*PrinterParameters\dmDefaultsource=value
Case "PRINTQUALITY"
*PrinterParameters\dmFields|#DM_PRINTQUALITY
*PrinterParameters\dmPrintquality=value
Case "COLOR"
*PrinterParameters\dmFields|#DM_COLOR
*PrinterParameters\dmColor=value
Case "DUPLEX"
*PrinterParameters\dmFields|#DM_DUPLEX
*PrinterParameters\dmDuplex=value
Case "YRESOLUTION"
*PrinterParameters\dmFields|#DM_YRESOLUTION
*PrinterParameters\dmYResolution=value
Case "TTOPTION"
*PrinterParameters\dmFields|#DM_TTOPTION
*PrinterParameters\dmTTOption=value
Case "COLLATE"
*PrinterParameters\dmFields|#DM_COLLATE
*PrinterParameters\dmCollate=value
EndSelect
Next
EndProcedure
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
Re: PrinterLib 1.10
That's what I was referring to.. It is already included w/PB.charvista wrote:It is strange. I implemented your Structure DEVMODE, the compiler then says:Thunder93 wrote:
w/PB It's named DEVMODEStructure already declared: DEVMODE (in a resident file)
What you looking for is...
DevMode.DEVMODE\Printer\dmOrientation
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Re: PrinterLib 1.10
YES! That was it! Thanks a lot!!Thunder93 wrote:
DevMode.DEVMODE\Printer\dmOrientation
Changed
To*PrinterParameters\dmOrientation=value
and it is working (again).*PrinterParameters\Printer\dmOrientation=value
Now I am wondering if that mistake was mine, or was it already in the original PureLib?....
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%