Invoke hidden commands in the twebbrowser
// The following Codes demonstrates an innovative way to invoke hidden
// Commands to show modal dialogs such as "add to favorite" dialog,
// "Import/Export wizard" dialog in your webbrowser-based application
// Command IDs handled by 'Shell docobject view'
Const id_ie_file_pagesetup = 259;
Const id_ie_file_print = 260;
Const id_ie_file_newwindow = 275;
Const id_ie_file_printpreview = 277;
Const id_ie_file_newmail = 279;
Const id_ie_file_sendpage = 282;
Const id_ie_file_sendlink = 283;
Const id_ie_file_send?top=cut = 284;
Const id_ie_help_versioninfo = 336;
Const id_ie_help_helpindex= 337;
Const id_ie_help_webtutorial = 338;
Const id_ie_help_freestuff = 341;
Const id_ie_help_productupdate = 342;
Const id_ie_help_faq = 343;
Const id_ie_help_onlinesupport = 344;
Const id_ie_help_feedback = 345;
Const id_ie_help_bestpage = 346;
Const id_ie_help_searchweb = 347;
Const id_ie_help_mshome = 348;
Const id_ie_help_visitinternet = 349;
Const id_ie_help_startpage = 350;
Const id_ie_help_netscapeuser = 351;
Const id_ie_file_importexport = 374;
Const id_ie_help_enhancedsecurity = 375;
Const id_ie_file_addtrusted = 376;
Const id_ie_file_addlocal = 377;
Const id_ie_file_newpublishinfo = 387;
Const id_ie_file_newpeople = 390;
Const id_ie_file_newcall = 395;
// Command IDs handled by 'Internet assumer_server'
Const id_ie_contextmenu_newwindow = 2137;
Const id_ie_contextmenu_addfav = 2261;
Const id_ie_contextmenu_refresh = 6042;
Function getiehandle (webbrowser: twebbrowser; classname: string): hwnd;
VaR
Hwndchild, hwndtmp: hwnd;
Olectrl: tolecontrol;
Szclass: array [0 .. 255] of char;
Begin
Olectrl: = webbrowser;
Hwndtmp: = olectrl. Handle;
While (true) Do
Begin
Hwndchild: = getwindow (hwndtmp, gw_child );
Getclassname (hwndchild, szclass, sizeof (szclass ));
If (string (szclass) = classname) then
Begin
Result: = hwndchild;
Exit;
End;
Hwndtmp: = hwndchild;
End;
Result: = 0;
End;
Procedure tform1.toolbutton2click (Sender: tobject );
Begin
// Invoke "add to favorite" Dialog
Sendmessage (getiehandle (Web, 'Internet assumer_server '), wm_command, id_ie_contextmenu_addfav, 0 );
End;
Procedure tform1.toolbutton3click (Sender: tobject );
Begin
// Invoke "Import/Export wizard" Dialog
Sendmessage (getiehandle (Web, 'Shell docobject view'), wm_command, id_ie_file_importexport, 0 );
End;
Procedure tform1.formcreate (Sender: tobject );
Begin
Web. Go ('HTTP: // http://www.swissdelphicenter.ch/en ');
End;