Demonstrates how to save/print a webpage, launch the Faq/Help and much more, using the SendMessage function.
$include "windowssdk.inc"
' Command IDs handled by the "Shell DocObject View" window:
$define ID_IE_FILE_SAVEAS 258
$define ID_IE_FILE_PAGESETUP 259
$define ID_IE_FILE_PRINT 260
$define ID_IE_FILE_NEWWINDOW 275
$define ID_IE_FILE_PRINTPREVIEW 277
$define ID_IE_FILE_NEWMAIL 279
$define ID_IE_FILE_SENDDESKTOPSHORTCUT 284
$define ID_IE_HELP_ABOUTIE 336
$define ID_IE_HELP_HELPINDEX 337
$define ID_IE_HELP_WEBTUTORIAL 338
$define ID_IE_HELP_FREESTUFF 341
$define ID_IE_HELP_PRODUCTUPDATE 342
$define ID_IE_HELP_FAQ 343
$define ID_IE_HELP_ONLINESUPPORT 344
$define ID_IE_HELP_FEEDBACK 345
$define ID_IE_HELP_BESTPAGE 346
$define ID_IE_HELP_SEARCHWEB 347
$define ID_IE_HELP_MSHOME 348
$define ID_IE_HELP_VISITINTERNET 349
$define ID_IE_HELP_STARTPAGE 350
$define ID_IE_FILE_IMPORTEXPORT 374
$define ID_IE_FILE_ADDTRUST 376
$define ID_IE_FILE_ADDLOCAL 377
$define ID_IE_FILE_NEWPUBLISHINFO 387
$define ID_IE_FILE_NEWCORRESPONDENT 390
$define ID_IE_FILE_NEWCALL 395
$define ID_IE_HELP_NETSCAPEUSER 351
$define ID_IE_HELP_ENHANCEDSECURITY 375
WINDOW win
HWND hwndShellDocObjectView
OPENWINDOW win,0,0,600,400,0x10CF0000,0,"Undocumented webbrowser commands",&win_handler
BEGININSERTMENU win,0
MENUTITLE "File"
BEGINPOPUP "New"
MENUITEM "Window",0,ID_IE_FILE_NEWWINDOW
MENUITEM "Email",0,ID_IE_FILE_NEWMAIL
MENUITEM "PUBLISHINFO",0,ID_IE_FILE_NEWPUBLISHINFO
MENUITEM "CORRESPONDENT",0,ID_IE_FILE_NEWCORRESPONDENT
MENUITEM "CALL",0,ID_IE_FILE_NEWCALL
ENDPOPUP
MENUITEM "Open...",0,1
MENUITEM "Save as...",0,ID_IE_FILE_SAVEAS
SEPARATOR
MENUITEM "Print",0,ID_IE_FILE_PRINT
MENUITEM "Print Preview...",0,ID_IE_FILE_PRINTPREVIEW
MENUITEM "Print Setup...",0,ID_IE_FILE_PAGESETUP
SEPARATOR
MENUITEM "Create Shortcut on desktop",0,ID_IE_FILE_SENDDESKTOPSHORTCUT
MENUITEM "Import/Export",0,ID_IE_FILE_IMPORTEXPORT
BEGINPOPUP "Add"
MENUITEM "TRUST",0,ID_IE_FILE_ADDTRUST
MENUITEM "LOCAL",0,ID_IE_FILE_ADDLOCAL
ENDPOPUP
SEPARATOR
MENUITEM "Exit",0,2
' MENUTITLE "View"
' MENUTITLE "Favorites"
MENUTITLE "Help"
MENUITEM "Help Index",0,ID_IE_HELP_HELPINDEX
MENUITEM "Faq",0,ID_IE_HELP_FAQ
MENUITEM "For Netscape Users",0,ID_IE_HELP_NETSCAPEUSER
MENUITEM "Tutorial",0,ID_IE_HELP_WEBTUTORIAL
SEPARATOR
MENUITEM "Best Page",0,ID_IE_HELP_BESTPAGE
MENUITEM "Enhanced Security",0,ID_IE_HELP_ENHANCEDSECURITY
MENUITEM "Free Stuff",0,ID_IE_HELP_FREESTUFF
MENUITEM "Ms Home",0,ID_IE_HELP_MSHOME
MENUITEM "Search",0,ID_IE_HELP_SEARCHWEB
MENUITEM "Start Page",0,ID_IE_HELP_STARTPAGE
MENUITEM "Visit Internet",0,ID_IE_HELP_VISITINTERNET
SEPARATOR
MENUITEM "Online Support",0,ID_IE_HELP_ONLINESUPPORT
MENUITEM "Send Feedback",0,ID_IE_HELP_FEEDBACK
MENUITEM "Windows Update",0,ID_IE_HELP_PRODUCTUPDATE
SEPARATOR
MENUITEM "About",0,ID_IE_HELP_ABOUTIE
ENDMENU
BROWSECMD win, @NAVIGATE, "about:blank"
BROWSECMD win, @NAVIGATE, "http://news.google.com/"
while (win.hwnd and (hwndShellDocObjectView=0))
wait
hwndShellDocObjectView = GetWindow(win.hwnd, GW_CHILD)
endwhile
waituntil win.hwnd = 0
sub win_handler
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW win
if (AttachBrowser(win)) then CLOSEWINDOW win
CASE @IDMENUPICK
if (@WPARAM = 2) then SendMessage(win, WM_CLOSE, 0, 0)
if ((@WPARAM >= ID_IE_FILE_SAVEAS) and (@WPARAM <= ID_IE_HELP_ENHANCEDSECURITY))
SendMessageA(hwndShellDocObjectView, WM_COMMAND, @WPARAM, 0)
endif
CASE @IDCLOSEWINDOW
CLOSEWINDOW win
ENDSELECT
RETURN
ENDSUB
Dear Sapero:
I am looking for a command to show the
"Page Source" of a web page in Notepad.
Is there an "undocumented webbrowser
command" for this?
Regards, Don Smith
Sure, but this is documented: http://support.microsoft.com/kb/175513/en-us
$include "exdisp.inc"
$define HTMLID_FIND 1
$define HTMLID_VIEWSOURCE 2
$define HTMLID_OPTIONS 3
extern _CGID_IWebBrowser as GUID ' in sdkincludes.lib
sub ShowSource(WINDOW browserwindow)
IWebBrowser2 browser
if (BrowserFromWindow(browserwindow, &browser))
IDispatch disp
if ((browser->get_Document(&disp)=S_OK) and disp)
IOleCommandTarget cmd
if (disp->QueryInterface(_IID_IOleCommandTarget, &cmd) = S_OK)
cmd->Exec(_CGID_IWebBrowser, HTMLID_VIEWSOURCE, OLECMDEXECOPT_DODEFAULT, NULL, NULL)
cmd->Release()
endif
disp->Release()
endif
browser->Release()
endif
endsub
sub BrowserFromWindow(WINDOW w, pointer ppBrowser),BOOL
pointer p = GetProp(w.hwnd, "BROWSER")
BOOL success = FALSE
*<int>ppBrowser = 0
if (p)
IUnknown unk = *<comref>p
if (unk <> 0)
success = (unk->QueryInterface(_IID_IWebBrowser2, ppBrowser) = 0)
endif
endif
return success
endsub
Dear Sapero:
I am having a difficult time with your code. There are multiple errors in the SUB. Here are the errors:
==============================================================
sub ShowSource(WINDOW browserwindow)
IWebBrowser2 browser '--------------------------------------->unknown type
if (BrowserFromWindow(browserwindow, &browser))
'--------------->Warning: undeclared function
'---ALSO----->BrowserFromWindows,undefined
'---ALSO----->undefined variable browser
'---ALSO----->Invalid & operation
IDispatch disp
if ((browser->get_Document(&disp)=S_OK) and disp)
'--------------->undefined variable browser
'---ALSO----->invalid argument
'---ALSO----->undeclared method
'---ALSO----->Invalid comparison
'---ALSO----->Warning: Uninitialized variable: disp
IOleCommandTarget cmd '------------>unknown type
if (disp->QueryInterface(_IID_IOleCommandTarget, &cmd) = S_OK)
'---------------------------------->Invalid variable cmd
'---ALSO------------------------>Invalid & operation
'---ALSO------------------------>Invalid parameter
'---ALSO------------------------>undefined variable _IID_IO1eCommand Target
'---ALSO------------------------>Invalid parameter
cmd->Exec(_CGID_IWebBrowser, HTMLID_VIEWSOURCE, OLECMDEXECOPT_DODEFAULT, NULL, NULL)
'------------------------------->Invalid variable cmd )
'------------------------------->Invalid agrument )
'------------------------------->undeclared method
cmd->Release()
'----------------------->undefined variable cmd )
'---ALSO------------->invalid argument )
'---ALSO------------->undeclared method
endif
disp->Release()
endif
browser->Release()
'---------------------------->undefined variable browser )
'---ALSO------------------>invalid argument )
'---ALSO------------------>undeclared method
endif
endsub
==============================================================
Is it possible that the code was written for Aurora? I am attempting to use this in my browser program:
http://www.ionicwind.com/forums/index.php/topic,3158.0.html (http://www.ionicwind.com/forums/index.php/topic,3158.0.html)
Best regards, Don Smith
I compiled it with EBasic and it compiles just fine.
My 1st guess is you tried to insert this EBasic code into a CBasic program.
2nd guess is that $include "exdisp.inc"is missing
Larry
Thanks, Larry. Actually, it started out as a CBasic program and
when I purchased EBasic I converted it to EBasic and made the
necessary changes so that it would compile under EBasic.
I did have the expression $include "exdisp.inc" in the code.
Still had lots of errors in the SUB. Obviously, there is some
work I have to do.
But, thanks for the clue about CBasic. I'll start there.
Cordially, Don Smith
================================================
Today is April 15th and I have most of the problems solved. I need to learn
about external libraries. Since I am a new user of Ionic Software (2 months) and
I have just received my copy of the "Emergence BASIC Users Guide", I am
going to halt all programming until I've have a chance to read it in its entirety.
Fortunately, I am one of those curious people who enjoy reading users manuals.
HA. Chiou, Don