Mega Code Archive

 
Categories / Delphi / Examples
 

Webbrowser

uh... ok or if you want something quick and dirty (add SHELLAPI to your uses clause) To open a web page in the default browser ShellExecute(0,'open','http://www.myurl.com',nil,nil,SW_SHOWNORMAL); alternatively E-mailing from the default client ShellExecute(0,'open', 'mailto:me@mydomain.com?subject=EmailSubject&body=This is the message' ,nil,nil,SW_SHOWNORMAL); The subject and body parameters are optional. if you don't add the ?subject or &body these will be blank. The 'open' parameter can also be used to print or something else (with a wav play for instance). Look in the OLH 'ShellExecute' for more info. You can basically start anything for which you have a program associated. | |uses ...,ShellAPI; | | | |procedure TForm1.BrowseTo(sURL, sBrowser, sDir :String); |var | sei : TShellExecuteInfo; |begin | ZeroMemory(@sei, sizeof(sei)); | with sei do | begin | cbSize := SizeOf(sei); | fMask := SEE_MASK_NOCLOSEPROCESS; | Wnd := Form1.Handle; | lpVerb := 'open'; | // Need to see if sBrowser empty, if so, pass url to |lpFile parameter | if sBrowser <> #0 then | lpFile := PChar(sBrowser) | else | lpFile := PChar(sURL); | lpParameters := PChar(sURL); | lpDirectory := PChar(sDir); | nShow := SW_SHOWNORMAL; | end; | ShellExecuteEX(@sei); |end; | |procedure TForm1.btnBrowseToClick(Sender: TObject); |begin | BrowseTo('http://www.undu.com', '', | '"C:\Program Files\Netscape\Navigator\Program\"'); |end; | |>-----Original Message----- |>From: delphi-admin@elists.org [mailto:delphi-admin@elists.org]On Behalf >Of Kovacs Zoltan >Sent: Monday, September 25, 2000 6:14 AM >To: delphi@elists.org >Subject: Open the default Web Browser > > >Hello ! > >I have a quite simle question. >In my application I'd like to crete a menu (a button, etc.), when the >user clicks >on it, my default Web browser open, and display my Web Page. >I still use Deplhi 3, plese send the simplest solution(s). > >Thanks, Zoli ******************************************************************* or (much simpler) You can do this: uses ShellAPI; procedure TfrmAbout.lblWEBClick(Sender: TObject); begin ShellExecute(0, 'open', 'http://www.scalabium.com', nil, nil, SW_SHOWNORMAL); end;