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]