Prev: EjectNtmsMedia
Next: MSCOMM and Binary
From: Mike Williams on 7 Aug 2006 21:16 "Helge Haensel" <dj1wm(a)nurfuerspam.de> wrote in message news:op.tdw5k1b6sjedh2(a)hhh... .. . . by the way, I've just realised why it may not be working for you. In your post you said, "the PDF995-printer is not accepted". I'm not sure exactly what you mean by that, but it works fine here and I can certainly select it as the desired output printer. Are you perhaps showing a CommonDialog Control printer dialog and ticking the "Print to File" box in that dialog? If you are then that is why it isn't working for you. If you look at the readme.html file in the installation folder (usually Program Files / PDF995 folder) you will see that it specifically tells you NOT to tick the "Print to File" box. Just leave that box blank and the driver will print to a file anyway, and will pop up a standard file dialog for you. Anyway, all this stuff is pure conjecture on my part at the moment, because I don't yet know what code you are using. Perhaps I'll be able to be of more help to you after you have responded to my previous post. Mike
From: Helge Haensel on 8 Aug 2006 04:38 Am 08.08.2006, 03:16 Uhr, schrieb Mike Williams <Mike(a)WhiskyAndCoke.com>: > "Helge Haensel" <dj1wm(a)nurfuerspam.de> wrote in message > news:op.tdw5k1b6sjedh2(a)hhh... > > . . . by the way, I've just realised why it may not be working for you.. > In your post you said, "the PDF995-printer is not accepted". I'm not > sure exactly what you mean by that, but it works fine here and I can > certainly select it as the desired output printer. Are you perhaps > showing a CommonDialog Control printer dialog and ticking the "Print to > File" box in that dialog? If you are then that is why it isn't working > for you. If you look at the readme.html file in the installation folder > (usually Program Files / PDF995 folder) you will see that it > specifically tells you NOT to tick the "Print to File" box. Just leave > that box blank and the driver will print to a file anyway, and will pop > up a standard file dialog for you. Anyway, all this stuff is pure > conjecture on my part at the moment, because I don't yet know what code > you are using. Perhaps I'll be able to be of more help to you after you > have responded to my previous post. > > Mike > Hi Mike, nice to contact you directly. I wiil try to answer all your questions to my problems. Excuse my english it is probably a little bit more 'Americanese' - any way with errors. WindowsXP/HE SP2, OfficeXP/Pro SP3, VB5E The code i am using is from a msg of yours from thread 'Vb Printer Dialog Problems (VB6)' dated 29.06.2006. I simply put it here: Option Explicit Private Const OUT_DEFAULT_PRECIS = 0 Private Const CLIP_DEFAULT_PRECIS = 0 Private Const DEFAULT_QUALITY = 0 Private Const DEFAULT_PITCH = 0 Private Const FF_ROMAN = 16 Private Const CCHDEVICENAME = 32 Private Const CCHFORMNAME = 32 Private Const GMEM_MOVEABLE = &H2 Private Const GMEM_ZEROINIT = &H40 Private Const DM_DUPLEX = &H1000& Private Const DM_ORIENTATION = &H1& Private Const PD_PRINTSETUP = &H40 Private Const PD_DISABLEPRINTTOFILE = &H80000 Private Const PHYSICALOFFSETX As Long = 112 Private Const PHYSICALOFFSETY As Long = 113 Private Const OPAQUE = 0 Private Const TRANSPARENT = 1 Private Type POINTAPI x As Long y As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type PRINTDLG_TYPE lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long hdc As Long flags As Long nFromPage As Integer nToPage As Integer nMinPage As Integer nMaxPage As Integer nCopies As Integer hInstance As Long lCustData As Long lpfnPrintHook As Long lpfnSetupHook As Long lpPrintTemplateName As String lpSetupTemplateName As String hPrintTemplate As Long hSetupTemplate As Long End Type Private Type DEVNAMES_TYPE wDriverOffset As Integer wDeviceOffset As Integer wOutputOffset As Integer wDefault As Integer extra As String * 100 End Type Private Type DEVMODE_TYPE dmDeviceName As String * CCHDEVICENAME dmSpecVersion As Integer dmDriverVersion As Integer dmSize As Integer dmDriverExtra As Integer dmFields As Long dmOrientation As Integer dmPaperSize As Integer dmPaperLength As Integer dmPaperWidth As Integer dmScale As Integer dmCopies As Integer dmDefaultSource As Integer dmPrintQuality As Integer dmColor As Integer dmDuplex As Integer dmYResolution As Integer dmTTOption As Integer dmCollate As Integer dmFormName As String * CCHFORMNAME dmUnusedPadding As Integer dmBitsPerPel As Integer dmPelsWidth As Long dmPelsHeight As Long dmDisplayFlags As Long dmDisplayFrequency As Long End Type Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _ ByVal nindex As Long) As Long Private Declare Function PrintDialog Lib "comdlg32.dll" Alias "PrintDlgA" _ (pPrintdlg As PRINTDLG_TYPE) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long) Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As _ Long Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) _ As Long Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _ ByVal dwBytes As Long) As Long Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As _ Long Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal _ nBkMode As Long) As Long Private Sub SetPrinterOrigin(x As Single, y As Single) With Printer .ScaleLeft = .ScaleX(GetDeviceCaps(.hdc, PHYSICALOFFSETX), vbPixels, _ ..ScaleMode) - x .ScaleTop = .ScaleY(GetDeviceCaps(.hdc, PHYSICALOFFSETY), vbPixels, _ ..ScaleMode) - y .CurrentX = 0 .CurrentY = 0 End With End Sub Private Function PrintReport(frmOwner As Form, Optional InitialPrinter As _ String, _ Optional PrintFlags As Long) As Boolean Dim PrintDlg As PRINTDLG_TYPE Dim DevMode As DEVMODE_TYPE Dim DevName As DEVNAMES_TYPE Dim lpDevMode As Long, lpDevName As Long Dim bReturn As Integer, OriginalPrinter As String Dim objPrinter As Printer, NewPrinterName As String PrintDlg.lStructSize = Len(PrintDlg) PrintDlg.hwndOwner = frmOwner.hWnd PrintDlg.flags = PrintFlags On Error Resume Next ' save the current VB printer device name in case the user ' presses cancel and we need to restore it OriginalPrinter = Printer.DeviceName ' Set the initial printer in the dialog If Len(InitialPrinter) > 0 Then For Each objPrinter In Printers If InStr(1, objPrinter.DeviceName, InitialPrinter, vbTextCompare) > 0 _ Then 'hh If InStr(1, objPrinter.DeviceName, "PDF995", vbTextCompare) > 0 _ Then 'for testing purposes Set Printer = objPrinter Exit For End If Next End If ' DevMode.dmDeviceName = Printer.DeviceName DevMode.dmSize = Len(DevMode) DevMode.dmFields = DM_ORIENTATION Or DM_DUPLEX DevMode.dmPaperWidth = Printer.Width DevMode.dmOrientation = Printer.Orientation DevMode.dmPaperSize = Printer.PaperSize DevMode.dmDuplex = Printer.Duplex On Error GoTo 0 PrintDlg.hDevMode = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, _ Len(DevMode)) lpDevMode = GlobalLock(PrintDlg.hDevMode) If lpDevMode > 0 Then CopyMemory ByVal lpDevMode, DevMode, Len(DevMode) bReturn = GlobalUnlock(PrintDlg.hDevMode) End If
From: Mike Williams on 8 Aug 2006 12:43 "Helge Haensel" <dj1wm(a)nurfuerspam.de> wrote in message news:4jr3u7F9b4imU1(a)individual.net... > The code i am using is from a msg of yours from thread 'Vb > Printer Dialog Problems (VB6)' dated 29.06.2006. Before I start, I apologise if the group ends up getting two copies of this post. I'm having a problem with the server I use for this group at the moment and I'm not sure whether the post went off okay or not, so I've sent it again using Google Groups, just to make sure. Okay. I've just tried that code on my own system and it works fine with all printers, including the PDF995 driver. Everything works. There are some settings in the code that do not actually make sense for the PDF driver (for example PaperBin and Duplex settings) but those things are caught by the On Error Resume Next stuff, so they aren't a problem. It all works fine. On my system I can set the Windows default printer to anything I want and then use the code to print to any other installed printer, including to a pdf file using the PDF995 printer driver, and it works fine, printing the pdf file correctly without messing up the default printer at all. > WindowsXP/HE SP2, OfficeXP/Pro SP3, VB5E Right. I didn't realise you were using VB5. There were many problems with the VB5 printer driver (more than there are in VB6). Some of the VB5 printer problems were fixed by the various service packs and some were not. I've just installed my old "vanilla" version of VB5 (no service packs) and tried the same code again. In VB5 the same code did not work! It isn't a problem with any detail of the code, but rather a problem with the VB5 printer object. Even a simple Set Printer assignment does not work. It appears to work when you use the Set printer command (if you ask for the Printer.DeviceName it will tell you that the printer has been changed) but as soon as you actually try to use the printer it will simply reset itself to the default. On my standard vanilla VB5 installation this happens for all printers, not just the PDF995 driver. For example, try the code at the end of this message. If you start off with a specific default printer and you use the code to change to another printer you will see that the Set printer line actually works. However, as soon as you use Printer.Print (or anything else really) the printer resets itself back to the default. This happens on my own WinXP SP2 Home system using a vanilla installation of VB5. I'm not sure if the problem was ever fixed by any of the VB5 service packs, and I can't seem to find an old VB5 service pack to try it with. Maybe you can check it on your own system? What service pack do you use? > Now i am very keen for your answer and hope my problems > will not keep you to much off your businesswork. Don't worry about it. I like problems ;-) By the way, I can write some code for you that will definitely allow you to do what you want (select and use any printer other than the default) and that code will definitely work on all systems using either VB6 or VB5 with or without service packs and it will work with all printers, including the PDF995 driver. However, such code will require you to print your stuff using the various API functions instead of the standard VB Printer Object methods. So, for simplicity it might be wise to check out the behaviour of the VB Printer object using the latest VB5 service pack. Let me know which Service Pack you are using, and if it is not the latest one then perhaps you (or someone else here) might be able to tell us where we can download it. The Microsoft web pages seem to be extremely short of VB5 stuff these days! (Unless of course you also have VB6, in which case you should use that instead of VB5). > I need an equivalent to the VB PinterObject statement > 'Form7.PrintForm' because I have a form7 (overlarged > poscard size) that after positioning controls and setting > the printer param's will be printed about 300 times > with different text-contents coming from a database. I usually advise people against dumping Forms to the printer, whatever method they use, because of the limited resolution. I usually advise people to instead draw their stuff directly to the printer using the various Printer object drawing and printing methods, which are capable of giving you a high resolution output. But if you really do want to dump low resolution Form bitmaps to the printer then I can help you with it. However, it would be wise to get the problem with the VB5 Set printer method sorted out first. Try the code at the end of this message and let me know how it behaves on your own version of VB5. If, as I suspect, it fails to set the Printer correctly then you can try updating to a later VB5 service pack and trying it again. If you are still stuck after doing that then I'll help you out with the alternative API printing method I have mentioned. Let me know how it goes. > Is your return address working? Mine is. Otherwise > we will extend the thread here for nobodies interest. The return address shown in my postings is a dummy (a protection against spammers who farm the newsgroups for addresses). However, I'm certainly prepared to let you have my real email address if you wish. For the moment though I'd prefer to carry this thread on in the newsgroup because there are often people who are interested in the outcome of certain threads even if they don't actively participate in them. I'll mail you my address as soon as I finish this message, but (as I've said) I'd still prefer you to continue this thread in the group, even if you decide to additionally mail me privately, just in case there are others who are interested. For example, I'm sure there are many people with various VB5 service packs who might like to let us know how the sample code (below) behaves on their system. (Addendum: I've just looked at your return address and there appears to be some sort of "no spam" stuff in it, but since it's not in English I can't quite make up my mind which bits to delete to correct it). When you have checked out the sample code (below) don't worry if the VB5 Printer Object won't work properly even with all the service packs installed. As I've said, it will work under VB6 (if you have that) and in any case there are other much more reliable ways of going about this job which will work in any version of VB5 and VB6. But I'd prefer to attempt the
From: Mike Williams on 8 Aug 2006 14:13 Helge Haensel wrote: > [lots of stuff] .. . . by the way, I've just been doing a little bit of digging around and I'm fairly certain that the failure of the VB5 printer object to retain its "Set Printer" setting as soon as any one of a number of printer methods or properties are accessed was fixed in VB5 Service Pack 3. At the moment I'm having trouble finding a copy of VB5 SP3 to try it out, but I'm almost certain that if you find it and install it your "Set Printer" problem will be fixed. Can anyone else here provide a reliable link to a VB5 service pack download? Once you have downloaded and installed the service pack let me know if it fixes the "Set Printer" problem for you.I'll then help you with the other problems you mentioned, if you still have any. Don't forget to let me know if VB5 SP3 fixes the Set printer problem for you. I Iike to keep tabs on these things ;-) Mike Williams (MVP - Visual Basic)
From: Helge Haensel on 8 Aug 2006 14:26
Am 08.08.2006, 18:43 Uhr, schrieb Mike Williams <gagamomo(a)yahoo.co.uk>: Hi Mike, thanks for the very informative answer. I will answer your msg in parts because it so long. My return-address is absolutely ok as given. OK, we will stay in the thread, no problem. I have no idea of service packs with my vb5. There is no entry under Menue->'?'->Info. Should i look elsewhere? I started with VB5 under W98Se. then i changed to WiXP/HE. I have a file vb5sp3.exe (~12 Mb) in the VB-Folder. But i didnt install that because i do not know if it is helpful with XP or eventually confusing my VB5/W98 projects. I have an other vb5 Project (it's a big family tree) where the PrinterObject works. Only the Printerdialog doesnt show. Landscape'ing is ok. I immediately checked your code you included with your msg. I have fax, hp deskjet 970Cxi(hp) and PDF995 installed. Using stictly your code gives: Pressing cmd1 brings hp (Original default) hp (On using Printer.Print) MsgBox-Msg is not coming up hp: Pressing cmd1 brings hp (Original default) and Msg "Changing to Canon Printer" -> OK hp (After using Set Printer) hp (On using Printer.Print) PDF995: Pressing cmd1 brings hp (Original default) and Msg "Changing to Canon Printer" -> OK PDF995 (After using Set Printer) hp (On using Printer.Print) Fax: Pressing cmd1 brings hp (Original default) and Msg "Changing to Canon Printer" -> OK Fax (After using Set Printer) hp (On using Printer.Print) Commenting 'Printer.Print' now gives: hp (Original default) hp (On using Printer.Print) MsgBox-Msg is not coming up hp: Pressing cmd1 brings hp (Original default) and Msg "Changing to Canon Printer" -> OK hp (After using Set Printer) hp (On using Printer.Print) PDF995: Pressing cmd1 brings hp (Original default) and Msg "Changing to Canon Printer" -> OK PDF995 (After using Set Printer) PDF995 (On using Printer.Print) Fax: Pressing cmd1 brings hp (Original default) and Msg "Changing to Canon Printer" -> OK Fax (After using Set Printer) Fax (On using Printer.Print) This msg as a quicky! Helge |