AutoHotkey Community

It is currently May 26th, 2012, 9:40 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: September 18th, 2009, 6:39 am 
Offline

Joined: February 11th, 2007, 4:10 pm
Posts: 185
1.
I can Call PrintDlg to display the print dialog via the same method while PrintDlgEx can't. What's wrong about my funciton?

Code:
/*
typedef struct tagPDEX {
    DWORD lStructSize;
    HWND hwndOwner;
    HGLOBAL hDevMode;
    HGLOBAL hDevNames;
    HDC hDC;
    DWORD Flags;
    DWORD Flags2;
    DWORD ExclusionFlags;
    DWORD nPageRanges;
    DWORD nMaxPageRanges;
    LPPRINTPAGERANGE lpPageRanges;
    DWORD nMinPage;
    DWORD nMaxPage;
    DWORD nCopies;
    HINSTANCE hInstance;
    LPCTSTR lpPrintTemplateName;
    LPUNKNOWN lpCallback;
    DWORD nPropertyPages;
    HPROPSHEETPAGE *lphPropertyPages;
    DWORD nStartPage;
    DWORD dwResultAction;
} PRINTDLGEX, *LPPRINTDLGEX;
*/

Printer_LoadPrintDlgEx(hParent)
{
   VarSetCapacity(structPDX, SizeOf_structPDX := 84, 0)
   NumPut(SizeOf_structPDX, structPDX, 0)
   NumPut(hParent, structPDX, 4)   ; hwndOwner, diffrent from PrintDlg, it can't be null
   PD_NOPAGENUMS:=0x8   ; if the PD_NOPAGENUMS flag is not specified, lpPageRanges must be non-NULL.
   PD_RETURNDC:=0x100
   NumPut(PD_RETURNDC | PD_NOPAGENUMS, structPDX, 20)
   DllCall("comdlg32\PrintDlgExA", "UInt", &structPDX)
   hDC := NumGet(structPDX, 16)

   Return hDC
}


2.
Another problem is that when I should add "A" or "W" to the called funtion. It seems no need to do so for many other funtions, but GetDefaultPrinter, PrintDlg, PrintDlgEx, etc , can't work without the suffix.

3.
Code:
   nSize := VarSetCapacity(sPrinterName, 256)
   DllCall("winspool.drv\GetDefaultPrinterA", "Str", sPrinterName, "UIntP", nSize)
   VarSetCapacity(hPrinter, 4)
   DllCall("winspool.drv\OpenPrinterA", "Str", sPrinterName, "Int", hPrinter, "UInt", 0)
   MsgBox % hPrinter


hPrinter retrun null, what's the problem?[/code]


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 18th, 2009, 7:16 am 
Online
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Quote:
2.
Another problem is that when I should add "A" or "W" to the called funtion. It seems no need to do so for many other funtions, but GetDefaultPrinter, PrintDlg, PrintDlgEx, etc , can't work without the suffix.


  • "A' stands for Ansi and "W" for Unicode ( Wide Character )
  • For DllCall(), the first parameter should be the exact exported function name ( case sensitive ), and if not, AHK would return an errorlevel of -4
    Quote:
    -4: The specified function could not be found inside the DLL.

    Note: I have seen Lexikos mentioning elsewhere that AHK automatically appends an "A" to function names, but I am unsure
  • To view the exported functions of a DLL, you may use Dependency Walker

    Image

Quote:
3.
hPrinter retrun null, what's the problem?


Code:
nSize := VarSetCapacity( sPrinterName,256 )
DllCall( "winspool.drv\GetDefaultPrinterA", Str,sPrinterName, UIntP,nSize )
DllCall( "winspool.drv\OpenPrinterA", Str,sPrinterName, IntP,hPrinter, UInt,0 )
MsgBox % sPrinterName "`n" hPrinter


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 19th, 2009, 4:54 pm 
Offline

Joined: February 11th, 2007, 4:10 pm
Posts: 185
thx ,SKAN, it's a good utility.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, JSLover, patgenn123, rbrtryn, virpara and 58 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