Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Implement ForwardBackCancel buttons in TWebbrowser

Title: implement Forward/Back/Cancel buttons in TWebbrowser? { WhenhostingtheTWebbrowsercontrol,itmaybedesirabletoimplement Forward/Back/CancelbuttonssimilartothosethatInternetExplorerimplements. TheWebBrowsercontrolsupportsaCommandStateChange()event, whichisfiredwhenevertheForward/Back/Cancelbuttonneedtobeenabledordisabled. TheCommandStateChangeeventissentwithtwoparameters:aconstantindicating thetypeofbutton(CSC_NAVIGATEFORWARDorCSC_NAVIGATEBACKorCSC_UPDATECOMMANDS), andaBooleanflagindicatingwhethertoenableordisablethebutton. } { BeimTWebbrowseristesvielleichtwnschenswert,wenneszugehrigeButtons wieVorwrts/Rckwrts/Abbrechengibt(siehez.BInternetExplorer). EsgibteinCommandStateChange()Ereignis,welchesimmerdannausgelstwird, wennentwederderVorwrts/Rckwrts/Abbrechenaktiviertoderdeaktiviertwerden muss.CommandStateChange()hatzweiParameter:EineKonstante CSC_NAVIGATEFORWARDoderCSC_NAVIGATEBACKoderCSC_UPDATECOMMANDS,welcheangibt, welcherButtonbetroffenistundeinBooleanWert, welcherdenStatuseinesButtonangibt(aktiviertoderdeaktiviert) } //NavigatetoaURL //ZueinerURLnavigieren procedureTForm1.Button1Click(Sender:TObject); begin Webbrowser1.Navigate('www.SwissDelphiCenter.com'); end; //Catchtheeventsandsetabutton'sEnabledstate //DieEreignisseabfragenundden"Enabled"StatuseinesButtonssetzen procedureTForm1.WebBrowser1CommandStateChange(Sender:TObject; Command:Integer;Enable:WordBool); begin caseCommandof CSC_NAVIGATEBACK:ButtonBack.Enabled:=Enable; CSC_NAVIGATEFORWARD:ButtonForward.Enabled:=Enable; CSC_UPDATECOMMANDS:ButtonCancel.Enabled:=Enable; end; end; procedureTForm1.ButtonBackClick(Sender:TObject); begin WebBrowser1.GoBack end; procedureTForm1.ButtonForwardClick(Sender:TObject); begin WebBrowser1.GoForward end; procedureTForm1.ButtonCancelClick(Sender:TObject); begin WebBrowser1.Stop; end;