Microsoft & .NETVisual BasicDevelop Your Own Browser - Part 1

Develop Your Own Browser – Part 1

My code will be useful to You. So I am Submitting My code to you. I have retrieved some codes from MSDN Microsoft Web Workshop Website. See that to develop perfect Browser.Here ExecWB Method Contains Excellent (all) Features. My Webbrowser Control name is Webbrowser1 (brwwebbrowser).It Contains Page Setup, Printer Setup, Print, Send To, Properties, Save As coding to develop your own browser in your File Menu.

Insert this code into yourClick Event:

Dim eQuery As OLECMDF On Error Resume NexteQuery = webbrowser1.QueryStatusWB(OLECMDID_PAGESETUP)If Err.Number = 0 ThenIf eQuery And OLECMDF_ENABLED Thenwebbrowser1.ExecWB OLECMDID_PAGESETUP, _                   OLECMDEXECOPT_PROMPTUSER, _                   ,     Ok to Print?ElseMsgBox No contents of  WebbrowserEnd IfEnd If

Insert these declarations into your form declaration section

Private Declare Function PrinterProperties _        Lib winspool.drv _(ByVal hWnd As Long, ByVal hPrinter As Long) _        As LongPrivate Declare Function OpenPrinter _        Lib winspool.drv _Alias OpenPrinterA (ByVal pPrinterName _        As String, _phPrinter As Long, pDefault As PRINTER_DEFAULTS) _        As LongPrivate Declare Function ClosePrinter _        Lib winspool.drv _(ByVal hPrinter As Long) As LongPrivate Type PRINTER_DEFAULTSpDatatype As Long  StringpDevMode As LongpDesiredAccess As LongEnd TypePrivate Const STANDARD_RIGHTS_REQUIRED = &HF0000Private Const PRINTER_ACCESS_ADMINISTER = &H4Private Const PRINTER_ACCESS_USE = &H8Private Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or _PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE)

Then Insert these coding into your Click Event:

On Error Resume NextDim retval As Long, hPrinter As LongDim PD As PRINTER_DEFAULTSPD.pDatatype = 0PD.pDesiredAccess = STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_USEPD.pDevMode = 0retval = OpenPrinter(Printer.DeviceName, hPrinter, PD)If retval = 0 ThenMsgBox Printer Not FoundElseretval = PrinterProperties(Me.hWnd, hPrinter) retval = ClosePrinter(hPrinter)End If

Insert these coding into yourClick Event:

On Error Resume NextDim eQuery As OLECMDFeQuery = webbrowser1.QueryStatusWB(OLECMDID_PRINT)If Err.Number = 0 ThenIf eQuery And OLECMDF_ENABLED ThenWebbrowser1.ExecWB OLECMDID_PRINT, _                   OLECMDEXECOPT_PROMPTUSER, , _                       Ok to Print?ElseMsgBox Printer Not Found or No Contents in WebbrowserEnd IfEnd If

1.Add an Inet Control ( Component Microsoft Internet Transfer Control )
2.Add these line into your Click Event

Dim ss As String, sss As Stringss = InputBox(Enter file name to Save : )If Right(ss, 3) = .htm Thensss = A: & ssElsesss = A: & ss & .htmEnd IfDim b() As ByteInet1.CancelInet1.Protocol = icHTTPInet1.URL = webbrowser1.LocationNameb() = Inet1.OpenURL(, icByteArray)On Error GoTo ExtnOpen sss For Binary Access Write As #1Put #1, , b()Close #1MsgBox File Saved. Location is :  & sssExtn:If Err.Number = 71 ThenMsgBox There is no Floppy or it may be damaged.End If

Insert these coding into your Click Event:

Dim eQuery As OLECMDF    return value type for QueryStatusWBOn Error Resume NexteQuery = webbrowser1.QueryStatusWB(OLECMDID_PROPERTIES)If Err.Number = 0 ThenIf eQuery And OLECMDF_ENABLED ThenWebbrowser1.ExecWB OLECMDID_PROPERTIES, _                   OLECMDEXECOPT_PROMPTUSER, , _                         Ok to Print?ElseMsgBox No contents in WebbrowserEnd IfEnd If

Add an Inet Control (Component Microsoft Internet Transfer Control )
Add an Commondialong Control ( Component Microsoft Common Dialog Control)
Commondialong name commandialog1

Dim lrs As StringCommondialog1.ShowSavelrs = commaondialog1.FileNameIf Right(lrs, 4) = .htm Thenlrs = lrsElselrs = lrs & .htmEnd IfDim b() As ByteInet1.CancelInet1.Protocol = icHTTPInet1.URL = webbrowser1.locationnameIf Inet1.URL <>  Thenb() = Inet1.OpenURL(, icByteArray)Open lrs For Binary Access Write As #1Put #1, , b()Close #1End If

Get the Free Newsletter!
Subscribe to Developer Insider for top news, trends & analysis
This email address is invalid.
Get the Free Newsletter!
Subscribe to Developer Insider for top news, trends & analysis
This email address is invalid.

Latest Posts

Related Stories