eltorro Posted April 26, 2010 Share Posted April 26, 2010 (edited) Most print preview solutions use the MFC Doc/View architecture which limits it usefulness outside of c++. I found an article where a Delphi programmer used Enhanced Meta Files wrapped in a custom header and packaged together to create a print preview control. After a little more searching, It looks like using EMFs is a solution that would work.Some people suggest to create the document in Word or HTML and use Word or a browser to view it. Indeed, I have rendered documents to HTML and used the IE UDF to display the contents and/or print them. Not quite as ideal as one would like.Using GRS's printwin.au3 as a start, I came up with a print preview solution which others may be able to expand upon.The zip file contains the udf files necessary.Screenshot:Here is an example.expandcollapse popup#include <WinAPI.au3> #include "WinPrint.au3" #include "Preview.au3" #include "PrintDialog.au3" Global $PixelsPerInchY, $TwipsPerPixelY, $PixelsPerInchX, $TwipsPerPixelX, $PageWidth, $PageHeight ;1 print to default printer ;2 print preview ;3 use the second parameter as the device Context ;anything else, show printer dialog and get device context. _Print(2, 0) _ShowPreview() Func _Print($iMode = 0, $hPrintDC = 0) Local $s_DefaultPrinter, $s_DocName,$DocName, $DOCINFO, $result Switch $iMode Case 1, 2 ;print to default printer $s_DefaultPrinter = _WinSpool_GetDefaultPrinter() If $s_DefaultPrinter = "" Then Return SetError(1, 0, 0) $hPrintDC = _WinAPI_CreateDC("winspool", $s_DefaultPrinter) If $hPrintDC = 0 Then Return SetError(1, 0, 0) Case 3 ;use dc provided If $hPrintDC = 0 Then Return SetError(1, 0, 0) Case Else ;Show printer dialog Local $tPD $hPrintDC = _ShowPrintDialog($tPD) $tPD = 0 If $hPrintDC = 0 Then Return SetError(1, 0, 0) EndSwitch ; get pixel and twips info $PixelsPerInchY = _WinAPI_GetDeviceCaps($hPrintDC, $__WINAPICONSTANT_LOGPIXELSY) ; Get Pixels Per Inch Y $TwipsPerPixelY = 1440 / $PixelsPerInchY $PixelsPerInchX = _WinAPI_GetDeviceCaps($hPrintDC, $__WINAPICONSTANT_LOGPIXELSX) ; Get Pixels Per Inch X $TwipsPerPixelX = 1440 / $PixelsPerInchX ; get page width and height $PageWidth = _WinAPI_GetDeviceCaps($hPrintDC, $HORZRES) ; Get width, in millimeters, of the physical screen $PageHeight = _WinAPI_GetDeviceCaps($hPrintDC, $VERTRES) ; Get height, in millimeters, of the physical screen. Local $hBrush, $hBrushOld, $hLF, $hFont, $hOldFont, $DESIREDFONTSIZE, $s_TextOut Local $OutSize, $xLeft, $yTop, $tLF, $iColorOld, $LastPoint Local $hPen0,$hPen1,$hPen2,$hPen3,$hPen4,$hPen5,$hPen6,$hPen7,$hPen8,$hPen9,$hPenOld ; set docinfo $s_DocName = "Printing from AutoIt with WinAPI" $DocName = DllStructCreate("char DocName[" & StringLen($s_DocName & Chr(0)) & "]") DllStructSetData($DocName, "DocName", $s_DocName & Chr(0)) ; Size of DOCINFO structure ;$DocOutput = DllStructCreate("char DocOutput[" & StringLen($s_DocOutput & chr(0)) & "]") ;DllStructSetData($DocOutput, "DocOutput", $s_DocOutput) $DOCINFO = DllStructCreate($tagDOCINFO) ; Structure for Print Document info DllStructSetData($DOCINFO, "Size", 20) ; Size of DOCINFO structure DllStructSetData($DOCINFO, "DocName", DllStructGetPtr($DocName)) ; Set name of print job (Optional) ;DllStructSetData($DOCINFO, "Output", DllStructGetPtr($DocOutput)) ; Set name of print job (Optional) If $iMode = 2 Then $result += _MetaFile_StartDoc($hPrintDC, $DOCINFO) $result += _MetaFile_StartPage($hPrintDC) Else $result += _WinAPI_StartDoc($hPrintDC, $DOCINFO) ; start new page $result += _WinAPI_StartPage($hPrintDC) EndIf ; create font $DESIREDFONTSIZE = 18 $hFont = _WinAPI_CreateFont((($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY), 0, 0, 0, $FW_NORMAL, False, False, False _ , $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Times New Roman') ; set newfont, save old font $hOldFont = _WinAPI_SelectObject($hPrintDC, $hFont) ; print centered test message $s_TextOut = "This is a test..." $OutSize = _WinAPI_GetTextExtentPoint32($hPrintDC, $s_TextOut) ; Compute the starting point for the text-output operation(centered) $xLeft = (($PageWidth / 2) - (DllStructGetData($OutSize, "X") / 2)) ; Compute the starting point for the text-output 2 lines down $yTop = DllStructGetData($OutSize, "Y") * 2 ; Send text $xLeft = Inch2PixelX(0.781250) $yTop = Inch2PixelY(0.260417) $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; create font structure, rotated 180 degrees $tLF = DllStructCreate($tagLOGFONT) $DESIREDFONTSIZE = 12 DllStructSetData($tLF, "Escapement", 2700) DllStructSetData($tLF, "Height", (($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY)) DllStructSetData($tLF, "Italic", False) DllStructSetData($tLF, "Underline", False) DllStructSetData($tLF, "FaceName", "Arial") ; set font $hLF = _WinAPI_CreateFontIndirect($tLF) $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; Send rotated text to printer, starting at location 1000, 1000 $xLeft = 1000 $yTop = 1000 $s_TextOut = "Testing...123" $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; update font _WinAPI_DeleteObject($tLF) DllStructSetData($tLF, "Escapement", 2250) $hLF = _WinAPI_CreateFontIndirect($tLF) $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; Send rotated text to printer, starting at location 1000, 1000 $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; update font _WinAPI_DeleteObject($hLF) $hLF = _WinAPI_CreateFont((($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY), 0, 1800, 0, $FW_NORMAL, False, False, False _ , $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Arial') $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; Send rotated text to printer, starting at location 1000, 1000 $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; update font _WinAPI_DeleteObject($hLF) $hLF = _WinAPI_CreateFont((($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY), 0, 1500, 0, $FW_NORMAL, False, False, False _ , $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Arial') $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; Send rotated text to printer, starting at location 1000, 1000 $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; update font _WinAPI_DeleteObject($hLF) $hLF = _WinAPI_CreateFont((($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY), 0, 1200, 0, $FW_NORMAL, False, False, False _ , $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Arial') $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; Send rotated text to printer, starting at location 1000, 1000 $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; update font _WinAPI_DeleteObject($hLF) $hLF = _WinAPI_CreateFont((($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY), 0, 900, 0, $FW_NORMAL, False, False, False _ , $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Arial') $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; set textcolor, save last textcolor $iColorOld = _WinAPI_SetTextColor($hPrintDC, 0xFF0000) ; Send rotated text to printer, starting at location 1000, 1000 $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; update font _WinAPI_DeleteObject($hLF) $hLF = _WinAPI_CreateFont((($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY), 0, 600, 0, $FW_NORMAL, False, False, False _ , $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Arial') $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; set textcolor, save last textcolor $result += _WinAPI_SetTextColor($hPrintDC, 0x00FF00) ; Send rotated text to printer, starting at location 1000, 1000 $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; update font _WinAPI_DeleteObject($hLF) $hLF = _WinAPI_CreateFont((($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY), 0, 300, 0, $FW_NORMAL, False, False, False _ , $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Arial') $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; set textcolor, save last textcolor $result += _WinAPI_SetTextColor($hPrintDC, 0x0000FF) ; Send rotated text to printer, starting at location 1000, 1000 $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; update font _WinAPI_DeleteObject($hLF) $hLF = _WinAPI_CreateFont((($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY), 0, 0, 0, $FW_BOLD, False, False, False _ , $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Arial') $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; set textcolor, save last textcolor $result += _WinAPI_SetTextColor($hPrintDC, 0x0) ; Send rotated text to printer, starting at location 1000, 1000 $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; set textcolor $result += _WinAPI_SetTextColor($hPrintDC, 0x0000FF) ; restore original font $result += _WinAPI_SelectObject($hPrintDC, $hOldFont) ; restore original color $result += _WinAPI_SetTextColor($hPrintDC, $iColorOld) ; delete fonts _WinAPI_SelectObject($hPrintDC, $hOldFont) _WinAPI_DeleteObject($hFont) _WinAPI_DeleteObject($hLF) $tLF = 0 ; create pens to draw with (PenStyle, Width, RGB-Color) $hPen0 = _WinAPI_CreatePen($PS_SOLID, 0, 0x000000) $hPen1 = _WinAPI_CreatePen($PS_DASH, 0, 0x000000) $hPen2 = _WinAPI_CreatePen($PS_DOT, 0, 0x000000) $hPen3 = _WinAPI_CreatePen($PS_DASHDOT, 0, 0x000000) $hPen4 = _WinAPI_CreatePen($PS_DASHDOTDOT, 0, 0x000000) $hPen5 = _WinAPI_CreatePen($PS_SOLID, 20, 0x000000) $hPen6 = _WinAPI_CreatePen($PS_SOLID, 40, 0x000000) $hPen7 = _WinAPI_CreatePen($PS_SOLID, 40, 0x0000FF) $hPen8 = _WinAPI_CreatePen($PS_SOLID, 40, 0x00FF00) $hPen9 = _WinAPI_CreatePen($PS_SOLID, 40, 0xFF0000) ; set starting point $LastPoint = DllStructCreate($tagPOINT) $result += _WinAPI_MoveToEx($hPrintDC, 1000, 2000, $LastPoint) ; select pen, save old pen $hPenOld = _WinAPI_SelectObject($hPrintDC, $hPen2) ; draw line $result += _WinAPI_LineTo($hPrintDC, 1100, 3000) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen4) ; draw line $result += _WinAPI_LineTo($hPrintDC, 1200, 2000) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen3) ; draw line $result += _WinAPI_LineTo($hPrintDC, 1300, 3000) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen1) ; draw line $result += _WinAPI_LineTo($hPrintDC, 1400, 2000) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen0) ; draw line $result += _WinAPI_LineTo($hPrintDC, 1500, 3000) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen5) ; draw line $result += _WinAPI_LineTo($hPrintDC, 1600, 2000) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen6) ; draw line $result += _WinAPI_LineTo($hPrintDC, 1700, 3000) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen7) ; draw line $result += _WinAPI_LineTo($hPrintDC, 1800, 2000) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen8) ; draw line $result += _WinAPI_LineTo($hPrintDC, 1900, 3000) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen9) ; draw line $result += _WinAPI_LineTo($hPrintDC, 2000, 2000) ; draw arch connected from current point $result += _WinAPI_SetArcDirection($hPrintDC, $AD_CLOCKWISE) $result += _WinAPI_ArcTo($hPrintDC, 2500, 2000, 3000, 2500, 2500, 2500, 3000, 2500) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen4) ; draw arch $result += _WinAPI_Arc($hPrintDC, 2500, 1000, 3500, 1500, 0, 0, 0, 0) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen5) ; create brush $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) ; select brush $hBrushOld = _WinAPI_SelectObject($hPrintDC, $hBrush) ; draw rectangles $result += _WinAPI_Rectangle($hPrintDC, 3500, 2000, 4500, 2500) $result += _WinAPI_RoundRect($hPrintDC, 3500, 2600, 4500, 3100, 200, 200) ; draw circle $result += _WinAPI_Ellipse($hPrintDC, 3300, 1800, 3700, 2200) ; restore original brush $result += _WinAPI_SelectObject($hPrintDC, $hBrushOld) ; select pen $result += _WinAPI_SelectObject($hPrintDC, $hPen2) $result += _WinAPI_Arc($hPrintDC, 3300, 1900, 3700, 2300, 0, 0, 0, 0) ;============================================================================== ; If $iMode = 2 Then ; End the page $result += _MetaFile_EndPage($hPrintDC) ; start new page $result += _MetaFile_StartPage($hPrintDC) ;Each page is a new dc. Else ; End the page $result += _WinAPI_EndPage($hPrintDC) ; start new page $result += _WinAPI_StartPage($hPrintDC) EndIf _WinAPI_DeleteObject($hLF) $hLF = _WinAPI_CreateFont((($DESIREDFONTSIZE * - 20) / $TwipsPerPixelY), 0, 0, 0, $FW_NORMAL, False, False, False _ , $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, 'Arial') $result += _WinAPI_SelectObject($hPrintDC, $hLF) ; print centered test message $s_TextOut = "This is page 2" $OutSize = _WinAPI_GetTextExtentPoint32($hPrintDC, $s_TextOut) ; Compute the starting point for the text-output operation(centered) $xLeft = (($PageWidth / 2) - (DllStructGetData($OutSize, "X") / 2)) ; Compute the starting point for the text-output 2 lines down $yTop = DllStructGetData($OutSize, "Y") * 2 ; Send text $result += _WinAPI_SetTextColor($hPrintDC, 0x0000FF) $result += _WinAPI_TextOut($hPrintDC, $xLeft, $yTop, $s_TextOut) ; restore original font $result += _WinAPI_SelectObject($hPrintDC, $hOldFont) ; restore original color $result += _WinAPI_SetTextColor($hPrintDC, $iColorOld) ; delete pens _WinAPI_DeleteObject($hPen0) _WinAPI_DeleteObject($hPen1) _WinAPI_DeleteObject($hPen2) _WinAPI_DeleteObject($hPen3) _WinAPI_DeleteObject($hPen4) _WinAPI_DeleteObject($hPen5) _WinAPI_DeleteObject($hPen6) _WinAPI_DeleteObject($hPen7) _WinAPI_DeleteObject($hPen8) _WinAPI_DeleteObject($hPen9) ; delete brush _WinAPI_DeleteObject($hBrush) ; delete font _WinAPI_DeleteObject($hLF) ; restore original font $result += _WinAPI_SelectObject($hPrintDC, $hOldFont) ; restore original pen $result += _WinAPI_SelectObject($hPrintDC, $hPenOld) ; restore original brush $result += _WinAPI_SelectObject($hPrintDC, $hBrushOld) If $iMode = 2 Then ; End the page $result += _MetaFile_EndPage($hPrintDC) ; End the print job $result += _MetaFile_EndDoc($hPrintDC) Else ; End the page $result += _WinAPI_EndPage($hPrintDC) ; End the print job $result += _WinAPI_EndDoc($hPrintDC) ; Delete the printer device context EndIf _WinAPI_ReleaseDC(0, $hPrintDC) _WinAPI_DeleteDC($hPrintDC) Return $result EndFunc ;==>_Print Func Inch2PixelX($iInchesx) Return Int($iInchesx * $PixelsPerInchX) EndFunc ;==>Inch2PixelX Func Inch2PixelY($iInchesy) Return Int($iInchesy * $PixelsPerInchY) EndFunc ;==>Inch2PixelYSome thing that needs to be noted are:Each "page" is a new device context. This is significant in that GDI objects (like fonts and brushes) loaded to the dc are lost with the dc then page ends. I could not find a way to clear the meta file and reuse to device context.The page size is fixed at letter size portrait.Each page is a separate emf file.The meta files are dumped into a temp folder with an ini file. The preview window reads the ini file for the title and page count then loads the preview. When the preview dialog is closed, the meta files and ini are erased.The zip file is here.The zip contains:WinPrint.au3 - GRS's printwin script modified.PrintDialog.au3 -- Show the printer common dialog.MetaFile.au3 -- Windows enhanced meta file api calls in AutoIt3Preview.au3 -- Shows the print preview window.PreviewTest.au3 -- A little demonstration.A basic overview for print preview:Include Preview.au3 Get a handle to a printer device context Setup the DOCINFO structure Use _MetaFIle_StartDoc in place of _WinAPI_StartDoc Use _MetaFile_StartPage in place of _WinAPI_StartPage Draw on the device context use gdi functions. Use _MetaFile_EndPage in place of _WinAPI_EndPage Repeat from _MetaFile_StartPage as necessary. Use _MetaFile_EndDoc in place of _WinAPI_EndDoc Call _ShowPreview()Please look at the example to see how it works.::eltorroedit: changed topic description, added link to top, added screenshot link. Edited April 27, 2010 by eltorro mLipok and Earthshine 2 Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
enaiman Posted April 27, 2010 Share Posted April 27, 2010 Nice job Earthshine 1 SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
eltorro Posted April 28, 2010 Author Share Posted April 28, 2010 Thanks Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
bowain Posted April 29, 2010 Share Posted April 29, 2010 (edited) Great work here. Took me the better part of yesterday to get it to read a text file then preview it, but kept going back to your example and finally got it to work. Thanks for your hard work. Edit: Just figured out ratings (yeah I know real hard there) and gave u 5 stars Edited April 29, 2010 by bowain Link to comment Share on other sites More sharing options...
eltorro Posted April 30, 2010 Author Share Posted April 30, 2010 Great work here. Took me the better part of yesterday to get it to read a text file then preview it, but kept going back to your example and finally got it to work.Thanks for your hard work.Edit: Just figured out ratings (yeah I know real hard there) and gave u 5 starsThanks.I'm working on displaying the preview in landscape. Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
bowain Posted May 1, 2010 Share Posted May 1, 2010 (edited) Thanks.I'm working on displaying the preview in landscape.Was working with this some more and noticed the resize (size to fit 100%) did not work, not really a big deal but was not sure if you knew or not. Also on the print feature (not sure if this is yours or Windows issue) but choosing one page to print (say page 2 to page 2) you still get the whole document. Again just a note and nothing that will stop me from using this. (giving all props to you for the print preview function )The landscape version would come in handy but not for the current project I am working on. I've pretty much stripped the GUI down to just a print, page advance and close button.Again Kudos! Edited May 1, 2010 by bowain Link to comment Share on other sites More sharing options...
eltorro Posted May 1, 2010 Author Share Posted May 1, 2010 Was working with this some more and noticed the resize (size to fit 100%) did not work, not really a big deal but was not sure if you knew or not. Also on the print feature (not sure if this is yours or Windows issue) but choosing one page to print (say page 2 to page 2) you still get the whole document. Again just a note and nothing that will stop me from using this. (giving all props to you for the print preview function )The landscape version would come in handy but not for the current project I am working on. I've pretty much stripped the GUI down to just a print, page advance and close button.Again Kudos! The resize combo box is basically a place holder for some scaling values and not hooked to msg loop yet. The page picking is a combination of both. One of the structures(PRINTDLG structure) used in the print setup dialogs takes the page ranges and passes them to the driver and is not yet filled in. Hopefully in the near future that part will be worked out. Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
eltorro Posted May 7, 2010 Author Share Posted May 7, 2010 Updated the code. Scaling is enabled. I did some work on the scroll bars.Links in first post Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
TheSaint Posted May 8, 2010 Share Posted May 8, 2010 Thanks for sharing! Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
rdwray Posted December 25, 2010 Share Posted December 25, 2010 I tried to use this and I did not get a preview. The hour glass came up, but nothing else. Thanks... “No other God have I but Thee; born in a manger, died on a tree.” Martin Luther Link to comment Share on other sites More sharing options...
TheCurrent Posted April 5, 2011 Share Posted April 5, 2011 thanks for this one, very useful. Link to comment Share on other sites More sharing options...
clustersblue Posted June 14, 2012 Share Posted June 14, 2012 Hi eltorro, Just started using your PrintDialog.au3 and WinPrintConstants.au3 and slightly modified one of your functions (see below code) under "PrintDialog.au3" by adding one line of code "$openPrintingPreferences=..." hope you don't mind. The purpose of that line is to invoke directly the Printing Preferences dialog which I did successfully. However, after setting the settings that I want (i.e. number of copies, paper size, paper type, etc...) then press OK it seems the devmode values were not updated. What I want really is for the user to be able to change the printer settings and then save the devmode data into a file for future use, using printUI. But it seems not, since when I restore the data the settings are still the default values. Is there something that I missed or did wrong? I'm not familiar how devmode structure works most likely I missed something. Func _Get_Devmode_Data($szPrinter = Default) If $szPrinter = Default Then $szPrinter = _WinSpool_GetDefaultPrinter() If $szPrinter = "" Then Return SetError(1,0,0) Local $phPrinter, $hPrinter, $tDM = 0, $modifiedtDM $phPrinter = DllStructCreate("ptr") If _WinSpool_OpenPrinter($szPrinter, $phPrinter, -1) Then $hPrinter = DllStructGetData($phPrinter, 1) Local $iNeeded = _WinSpool_DocumentProperties(0, $hPrinter, $szPrinter, $tDM, 0, 0) If $iNeeded > 218 Then $tDM = DllStructCreate($tagDEVMODE & ";byte[" & $iNeeded - 218 & "]") Else $tDM = DllStructCreate($tagDEVMODE) EndIf $iResult = _WinSpool_DocumentProperties(0, $hPrinter, $szPrinter, $tDM, 0, $DM_OUT_BUFFER) $openPrintingPreferences = _WinSpool_DocumentProperties(0, $hPrinter, $szPrinter, $tDM, $tDM, BitOR($DM_IN_BUFFER,$DM_OUT_BUFFER,$DM_IN_PROMPT)) $phPrinter = 0 _WinSpool_ClosePrinter($hPrinter) if $openPrintingPreferences ==1 Then if $iResult = 0 Then $tDM = 0 Return SetError(1,0,0) EndIf Return $tDM Else Return 2 EndIf EndIf Return SetError(1,0,0) EndFunc Your UDF works flawlessly out of the box, thanks for sharing! Link to comment Share on other sites More sharing options...
jcpetu Posted September 5, 2012 Share Posted September 5, 2012 Hi eltorro, how could I use your script to print for example a word document? Thks a lot and regards. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 5, 2012 Share Posted September 5, 2012 Unfortunately, eltorro hasn't been online here in nearly 2 years. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
jcpetu Posted September 5, 2012 Share Posted September 5, 2012 Ok, thanks BrewManNH. Link to comment Share on other sites More sharing options...
mesale0077 Posted September 5, 2013 Share Posted September 5, 2013 PrintPreview.zip new link please Link to comment Share on other sites More sharing options...
x_bennY Posted December 8, 2017 Share Posted December 8, 2017 (edited) someone has the link or the file to share? or another solution? i really need this. --------------------------------------------- Wow! Good news... after a long time of researching i found the file in a japonese forum! I'm attaching the original and the one that i've quickly edited to work on actual autoit version. I suggest to add this files into the forum database, at the download section. 459b1469257663.rar PrintPreview xbY.rar Edited December 8, 2017 by x_bennY Download link is broken, attaching the files. argumentum 1 Link to comment Share on other sites More sharing options...
argumentum Posted December 10, 2017 Share Posted December 10, 2017 On 12/8/2017 at 4:24 PM, x_bennY said: I suggest to add this files into the forum database, at the download section. https://www.autoitscript.com/forum/files/file/453-printpreviewzip/ Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now