Page 1 of 1

Printing from WebBrowser

Posted: Wed May 05, 2004 10:49 am
by rogal79
Can somebody help me to print a document from
WebBrowser but without header and footer
(or modify header and footer from PureBasic)?

This is a sample from this forum:

Code: Select all


Enumeration 1 
  #OLECMDID_OPEN          
  #OLECMDID_NEW        
  #OLECMDID_SAVE          
  #OLECMDID_SAVEAS            
  #OLECMDID_SAVECOPYAS    
  #OLECMDID_PRINT        
  #OLECMDID_PRINTPREVIEW        
  #OLECMDID_PAGESETUP        
  #OLECMDID_SPELL            
  #OLECMDID_PROPERTIES  
  #OLECMDID_CUT          
  #OLECMDID_COPY        
  #OLECMDID_PASTE            
  #OLECMDID_PASTESPECIAL    
  #OLECMDID_UNDO            
  #OLECMDID_REDO          
  #OLECMDID_SELECTALL        
  #OLECMDID_CLEARSELECTION 
  #OLECMDID_ZOOM            
  #OLECMDID_GETZOOMRANGE      
  #OLECMDID_UPDATECOMMANDS  
  #OLECMDID_REFRESH            
  #OLECMDID_STOP              
  #OLECMDID_HIDETOOLBARS      
  #OLECMDID_SETPROGRESSMAX    
  #OLECMDID_SETPROGRESSPOS  
  #OLECMDID_SETPROGRESSTEXT    
  #OLECMDID_SETTITLE          
  #OLECMDID_SETDOWNLOADSTATE  
  #OLECMDID_STOPDOWNLOAD
  #OLECMDID_FIND 
  #OLECMDID_DELETE 
  #OLECMDID_PRINT2 
  #OLECMDID_PRINTPREVIEW2
EndEnumeration 

Enumeration 0 
  #OLECMDEXECOPT_DODEFAULT      
  #OLECMDEXECOPT_PROMPTUSER        
  #OLECMDEXECOPT_DONTPROMPTUSER    
  #OLECMDEXECOPT_SHOWHELP        
EndEnumeration 

; ----------------------------------------------------- 

#WebGadget = 1 
#Button = 2 

OpenWindow(0, 0, 0, 800, 600, #PB_Window_ScreenCentered|#PB_Window_SystemMenu, "WebBrowser") 
CreateGadgetList(WindowID()) 

WebGadget(#WebGadget, 10, 40, 780, 550, "http://www.google.com")
ButtonGadget(#Button, 10, 10, 60, 20, "Print") 

; The IWebBrowser2 Interface is now defined in a .res file (with about 2000 others), 
; so there's no definition work for us to do :) 

; Fred the genius stored the Interface pointer to IWebBrowser2 in the DATA 
; member of the windowstructure of the WebGadget containerwindow, so we can get 
; that easily: 
WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(#WebGadget), #GWL_USERDATA) 

Repeat 
  event = WaitWindowEvent() 
  If event = #PB_EventGadget And EventGadgetID() = #Button 
    
    ; Send the Print Command to the WebGadget: 
    
    WebObject\ExecWB(#OLECMDID_PRINT, #OLECMDEXECOPT_PROMPTUSER, 0, 0)
    
    ; using #OLECMDEXECOPT_DONTPROMPTUSER as second argument will print without 
    ; the printrequester. 
    
    
  EndIf 
Until event = #PB_EventCloseWindow 

End


Posted: Wed May 05, 2004 11:05 am
by Edwin Knoppert
These items are set in the registry.
So removing them and restoring them afterwards could be an option.

Posted: Wed May 05, 2004 12:48 pm
by GeoTrail
You can alter this by going to File->Page Setup.
There you can alter the header and footer.

And I guess you can also do as Edwin suggested and make a temp backup of the settings before removing them prior to printing.

Posted: Wed May 05, 2004 2:30 pm
by Sparkie
Or try to make some use of this from MS KB Article #267240

Waaayyyy over my head so maybe someone else can provide some translation. :?

Posted: Fri May 07, 2004 9:59 am
by rogal79
Thanks. I've done it by setting registry keys.
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup
(header and footer)