Code : Tout sélectionner
#Web_IE = 0
Procedure.s GetKeyString(HKEY_Folder.l, key.s, Subkey.s)
Protected OpenKey.l, Type.l, cbData.l, *lpbData, ReturnValue.s
cbData = (#MAX_PATH * 2) + 2
*lpbData = AllocateMemory(cbData)
If RegOpenKeyEx_(HKEY_Folder, key, 0, #KEY_ALL_ACCESS, @OpenKey) = #ERROR_SUCCESS
If RegQueryValueEx_(OpenKey, Subkey, 0, @Type, *lpbData, @cbData) = #ERROR_SUCCESS
If Type = #REG_SZ
ReturnValue = PeekS(*lpbData)
EndIf
EndIf
RegCloseKey_(OpenKey)
EndIf
FreeMemory(*lpbData)
ProcedureReturn ReturnValue
EndProcedure
Procedure.l SetKeyString(HKEY_Folder.l, key.s, Subkey.s, Value.s)
Protected OpenKey.l, ReturnValue.l
If RegOpenKeyEx_(HKEY_Folder, key, 0, #KEY_ALL_ACCESS, @OpenKey) = #ERROR_SUCCESS
If RegSetValueEx_(OpenKey, Subkey, 0, #REG_SZ, @Value, Len(Value) + 1) = #ERROR_SUCCESS
ReturnValue = #True
EndIf
RegCloseKey_(OpenKey)
EndIf
ProcedureReturn ReturnValue
EndProcedure
; Allows to change the header and footer (you must restore the originals)
Procedure ModifyIEHeaderFooter(State.l) ; #TRUE : modify , #FALSE : reverse to original
Static FirstTime.l, IEHeader.s, IEFooter.s, IELeft.s, IERight.s, IEBottom.s
If FirstTime = 0
IEHeader = GetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "header") ; default : "&w&bPage &p de &P"
IEFooter = GetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "footer") ; default : "&u&b&d"
IELeft = GetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "margin_left") ; default : "0.750000"
IERight = GetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "margin_right") ; default : "0.750000"
IEBottom = GetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "margin_bottom") ; default : "0.750000"
FirstTime = 1
EndIf
If State = #True
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "header", "AQ-Viewer [Consultation de documents]&b&d")
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "footer", "&bPage &p/&P")
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "margin_left", "0.400000")
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "margin_right", "0.400000")
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "margin_bottom", "0.500000")
Else
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "header", IEHeader)
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "footer", IEFooter)
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "margin_left", IELeft)
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "margin_right", IERight)
SetKeyString(#HKEY_CURRENT_USER, "Software\Microsoft\Internet Explorer\PageSetup", "margin_bottom", IEBottom)
EndIf
EndProcedure
; Set URL
Procedure WebAfficheURL(Url.s)
WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(#Web_IE), #GWL_USERDATA)
SetGadgetText(#Web_IE, Url)
While WindowEvent() : Wend
EndProcedure
; PRINTING HTML FILES (WebGadget #Web_IE may be hidden)
;
WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(#Web_IE), #GWL_USERDATA)
; Print many HTML files (filenames in FichiersHTML())
ForEach FichiersHTML()
WebAfficheURL(FichiersHTML())
ModifyIEHeaderFooter(#True)
WebObject\ExecWB(#OLECMDID_PRINT, #OLECMDEXECOPT_DONTPROMPTUSER, 0, 0)
ModifyIEHeaderFooter(#False)
Next