AutoHotkey Community

It is currently May 27th, 2012, 8:15 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: January 14th, 2012, 6:17 am 
OK, this seems to fix it.

Change
Zed Gecko wrote:
Code:
   sizeDevMode := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "StrP", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 0)

   VarSetCapacity(pDevModeOutput , sizeDevMode, 0)
   out2 := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "StrP", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 2)

to
Code:
   sizeDevMode := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "Ptr", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 0, int)

   ; VarSetCapacity(pDevModeOutput , sizeDevMode, 0)
   VarSetCapacity(pDevModeOutput , A_PtrSize, 0)
; outputdebug, % "sizeDevMode: " sizeDevMode
   out2 := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "Ptr", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 2, int)


Why did you use StrP for the third parameter of DocumentProperties? Msdn says
msdn DocumentProperties wrote:
pDeviceName [in]

A pointer to a null-terminated string that specifies the name of the device for which the printer-configuration property sheet is displayed.
So it should be ptr.


Anyway congrats, the script run with the 64bit build printed out a red circle. The library seems to be very nice.

I have a question, is this library able to print out a text file and save it as a specified image format? Let's say, I want to create a print view of FileA.txt and save it as FileA.jpg.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 6:50 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
Wow, this is great. Many thanks!
Quote:
Why did you use StrP for the third parameter of DocumentProperties?
Well because
ahk-help wrote:
* or P
(suffix)
Append an asterisk (with optional preceding space) to any of the above types to cause the address of the argument to be passed rather than the value itself
so i thought, AHK-Vars are null-terminated strings, so StrP (and Str*) therefore are pointers to "a null-terminated string". And for all i could test (32bit) it worked. Seems 64bit is a bit more demanding.

Quote:
I have a question, is this library able to print out a text file and save it as a specified image format? Let's say, I want to create a print view of FileA.txt and save it as FileA.jpg.
well for the second part, yes saving as image.files should be doable, as the print is based on a GDI-Device Context. I'm just not shure if there is function for that in the gdip-lib already,
i'll look that up tomorrow, it's late here.
for the first part, i plan to write a wrapper for either the GDI or the GDI+ text-function, but that is future for now. But if you just want to print a text-file to an image-file, you won't need my lib, the gdip.ahk-lib should be enough there is a Gdip_TextToGraphics and a Gdip_SaveBitmapToFile in there.

So thanks again and good night, i'll report again on that topic tomorrow, if you are interested.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 10:19 am 
Offline
User avatar

Joined: May 28th, 2011, 9:03 am
Posts: 466
Location: Germany
Anonymous wrote:
Change ... to

Code:
sizeDevMode := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "Ptr", pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeInput, "UInt", 0, int)
No, pPrinterName is containing a string, so it must be
Code:
"Str", pPrinterName
; or
"Ptr", &pPrinterName

Code:
VarSetCapacity(pDevModeOutput , A_PtrSize, 0)
No, pDevModeOutput isn't a pointer-sized variable, e.g. its size is 1638 for my printer. So you must set the capacity to sizeDevMode.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 4:00 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
i'm in the land of confusion now.

i'm totally unsure about the pPrinterName issue.

my opinion about the capacity of sizeDevMode was the same as just me,
but guests version seems to work on both 32&64bit, oposed to mine.

So anyway, i need another test on 64bit, to see if the new proposal works.
Please test this on 64bit and report back:
Code:
 code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795


thanks again for all your contributions.


Last edited by Zed Gecko on January 28th, 2012, 2:59 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 5:24 pm 
Offline
User avatar

Joined: May 28th, 2011, 9:03 am
Posts: 466
Location: Germany
Moin Zed,

Code:
;   just me proposal   
   sizeDevMode := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "Ptr", &pPrinterName, "Ptr", 0, "Ptr", 0, "UInt", 0, "Int")
   MsgBox, 0, sizeDevMode, %sizeDevMode% ; for testing only
   VarSetCapacity(pDevModeOutput , sizeDevMode, 0)
   out2 := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "Ptr", &pPrinterName, "Ptr", &pDevModeOutput, "Ptr", 0, "UInt", 2, "Int")

     
   if ((dmOrientation = 1)||(dmOrientation = 2))
      NumPut(dmOrientation, pDevModeOutput, 44, "Short")
   if dmCopies is integer
   {   
      if (dmCopies > 0)
         NumPut(dmCopies, pDevModeOutput, 54, "Short")
   }
   if ((dmColor = 1)||(dmColor = 2))
      NumPut(dmColor, pDevModeOutput, 60, "Short")
;;;64 possible error abouve POINTL struct, is it a pointer?   
   out3 := DllCall("Winspool.drv\DocumentProperties", "Ptr", MainhWnd, "Ptr", pPrinter, "Ptr", &pPrinterName, "Ptr", &pDevModeOutput, "Ptr", &pDevModeOutput, "UInt", 10, "Int")
is working on Vista 32 with AHK 1.1.05 U32 and Win7 64 with AHK 1.1.05 U64


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 7:43 pm 
Zed Gecko wrote:
i'm totally unsure about the pPrinterName issue.
just me is right.

Quote:
my opinion about the capacity of sizeDevMode was the same as just me,
but guests version seems to work on both 32&64bit, oposed to mine.
I just chenged it to avoid to pass -1. So if sizeDevMode works, it should be it.

I'd like to here an opinion or correct infomation from an expert whether it should be UintP or PtrP mentioned in this post.

Quote:
for the first part, i plan to write a wrapper for either the GDI or the GDI+ text-function, but that is future for now.
That would be great to see. We would be able to create a web page screen short from it.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 14th, 2012, 10:00 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
interesting, confusing, but
everything seems OK now.
so thank you all for your help.
this is very probably the final version:
SGDIPrint.ahk
Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795
so i'm going to work on the aditional functions.
i'll start with getting a bitmap-copy of the printer-dc for previews and saveouts. then i'll do a text- and bitmap-put function.
Feel free to post more ideas, but don't expect to much.


btw:
Quote:
I'd like to here an opinion or correct infomation from an expert whether it should be UintP or PtrP mentioned in this post.
+1 for that


Last edited by Zed Gecko on January 28th, 2012, 2:59 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 15th, 2012, 11:21 am 
Offline
User avatar

Joined: May 28th, 2011, 9:03 am
Posts: 466
Location: Germany
Hi Zed,

there's still (at least) one 64-bit issue in your script:
Code:
   ; Get the newly created printer device context.
   if !(hDC := NumGet(PRINTDIALOG_STRUCT,16))
      return
should be
Code:
   ; Get the newly created printer device context.
   if !(hDC := NumGet(PRINTDIALOG_STRUCT,A_PtrSize * 4))
      return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 15th, 2012, 10:32 pm 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
thanks again.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 3:40 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
hi, i'm back with an extended version of the lib
the new (and more resource-demanding)functions allow to
draw on a GDI+ Bitmap first, so you can preview the print or save it to image-file,
and then copy it to the printer DC.

Again i need some Tester,
could you please test the lib with the new test-script (which saves the print as test.jpg prior to printing).

SGDIPrint.ahk
Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795


Last edited by Zed Gecko on January 28th, 2012, 2:58 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 7:34 am 
Zed Gecko wrote:
could you please test the lib with the new test-script (which saves the print as test.jpg prior to printing).

It's working here on Windows 7 Ultimate 64 bit, AutoHotkey 1.1.05.06 64 bit.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 24th, 2012, 5:13 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
thanks for all your help so far.
again, i need some testers for the new text-out function:
test.ahk
Code:
code removed due to protest.
http://www.autohotkey.com/forum/viewtopic.php?t=81795



Last edited by Zed Gecko on January 28th, 2012, 2:58 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 24th, 2012, 10:27 pm 
*bump*

please, this is the last function, i need some 64bit testers at least.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2012, 3:47 am 
Offline

Joined: September 23rd, 2006, 1:58 pm
Posts: 149
Thanks for all your help.
The SGDIPrint Library seems stable now and is therefore published.
You'll find it here: http://www.autohotkey.com/forum/viewtopic.php?t=81679


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, migz99, sjc1000, Yahoo [Bot] and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group