Código: Seleccionar todo
#include <APIDlgConstants.au3>
#include <Memory.au3>
#include <WinAPIDlg.au3>
#include <WinAPIFiles.au3>
#include <WindowsConstants.au3>
Global $hHandle = DllCallbackRegister("_PrintHookProc", "INT_PTR", "hwnd;UINT;wparam;lparam")
; Create PRINTDLG structure and set initial values for the number of copies, starting, and ending page
Local $tPRINTDLG = DllStructCreate($tagPRINTDLG)
DllStructSetData($tPRINTDLG, 'Size', DllStructGetSize($tPRINTDLG))
DllStructSetData($tPRINTDLG, 'Flags', BitOR($PD_PAGENUMS, $PD_SHOWHELP, $PD_ENABLEPRINTHOOK))
DllStructSetData($tPRINTDLG, 'FromPage', 2)
DllStructSetData($tPRINTDLG, 'ToPage', 3)
DllStructSetData($tPRINTDLG, 'MinPage', 1)
DllStructSetData($tPRINTDLG, 'MaxPage', 9)
DllStructSetData($tPRINTDLG, 'Copies', 4)
DllStructSetData($tPRINTDLG, 'PrintHook', DllCallbackGetPtr($hHandle))
; Create Print dialog box
If Not _WinAPI_PrintDlg($tPRINTDLG) Then
Exit
EndIf
; Show results
Local $hDevNames = DllStructGetData($tPRINTDLG, 'hDevNames')
Local $pDevNames = _MemGlobalLock($hDevNames)
Local $tDEVNAMES = DllStructCreate($tagDEVNAMES, $pDevNames)
ConsoleWrite('Printer: ' & _WinAPI_GetString($pDevNames + 2 * DllStructGetData($tDEVNAMES, 'DeviceOffset')))
If DllStructGetData($tDEVNAMES, 'Default') Then
ConsoleWrite(' (Default)' & @CRLF)
Else
ConsoleWrite(@CRLF)
EndIf
ConsoleWrite('First page: ' & DllStructGetData($tPRINTDLG, 'FromPage') & @CRLF)
ConsoleWrite('Last page: ' & DllStructGetData($tPRINTDLG, 'ToPage') & @CRLF)
ConsoleWrite('Copies: ' & DllStructGetData($tPRINTDLG, 'Copies') & @CRLF)
; Free global memory objects that contains a DEVMODE and DEVNAMES structures
_MemGlobalFree(DllStructGetData($tPRINTDLG, 'hDevMode'))
_MemGlobalFree($hDevNames)
DllCallbackFree($hHandle)
Func _PrintHookProc($hWnd, $iMsg, $wParam, $lParam)
Local $nID = BitAND($wParam, 0x0000FFFF)
If $iMsg = $WM_INITDIALOG Then
ControlHide($hWnd, "", "Button2")
EndIf
If $iMsg = $WM_COMMAND Then
Switch $nID
Case 1038
MsgBox(0, "Danyfirex", "Danyfirex says Hi!!!")
;~ ShellExecute("here your CHM file")
Return 0
EndSwitch
EndIf
Return 0
EndFunc ;==>_PrintHookProc
Saludos