Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Web browser control on main VFP screen?
Message
From
13/02/2004 13:04:55
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00877030
Message ID:
00877179
Views:
14
Hi Mel.

Is there a way to place the web browser control on the VFP main screen? I would like a web page to appear there.

This is what we had to say about it in Chapter 5 of MegaFox: 1002 Things You Wanted to Know About Extending VFP

How do I put a browser on the VFP desktop? (Example: frmdsktop.scx)

The trick here is to use a form which looks just like the Visual FoxPro desktop and contains an instance of our web browser control, together with a couple of simple controls that allow us to enter a URL and navigate to it.

In order to make the form look like the normal desktop, we need to get rid of the title bar and borders so we have set the following properties:
· BorderStyle = 0 To remove all borders from the form
· TitleBar = OFF To remove the title bar, complete with the control box, maximize and minimize, help and close buttons.
· Maximized = 2 To ensure that the form fills the available desktop
· AlwaysOnBottom = True To allow other windows to float over the browser so that we can continue working in VFP while the form is running.
**************************************************
*-- Form:         frmwbrow (d:\megafox\ch05\frmwbrow.scx)
*-- ParentClass:  xfrmstd (d:\megafox\ch05\genforms.vcx)
*-- BaseClass:    form
*-- Time Stamp:   12/18/01 10:12:06 AM
*
#INCLUDE "d:\megafox\ch05\olecmdconst.h"
*
DEFINE CLASS frmwbrow AS xfrmstd


	Top = 0
	Left = 0
	Height = 348
	Width = 656
	DoCreate = .T.
	Caption = "Using the Web Browser ActiveX Control"
	Name = "frmwbrow"


	ADD OBJECT pgfbrowser AS xpgfbase WITH ;
		ErasePage = .T., ;
		PageCount = 2, ;
		Top = 2, ;
		Left = 3, ;
		Width = 653, ;
		Height = 309, ;
		Name = "pgfbrowser", ;
		Page1.Caption = "Select Item", ;
		Page1.Name = "Page1", ;
		Page2.Caption = "Display Item", ;
		Page2.Name = "Page2"


	ADD OBJECT frmwbrow.pgfbrowser.page1.grditems AS xgrdbase WITH ;
		ColumnCount = 3, ;
		FontBold = .F., ;
		FontSize = 10, ;
		DeleteMark = .F., ;
		Height = 268, ;
		Left = 6, ;
		Panel = 1, ;
		RecordMark = .F., ;
		RecordSource = "showdata", ;
		RowHeight = 19, ;
		Top = 8, ;
		Visible = .T., ;
		Width = 638, ;
		BackColor = RGB(196,221,255), ;
		Name = "grdItems", ;
		Column1.FontBold = .F., ;
		Column1.FontSize = 10, ;
		Column1.Alignment = 0, ;
		Column1.ControlSource = "showdata.ctype", ;
		Column1.Width = 94, ;
		Column1.ReadOnly = .T., ;
		Column1.Visible = .T., ;
		Column1.BackColor = RGB(196,221,255), ;
		Column1.Name = "coltype", ;
		Column2.FontBold = .F., ;
		Column2.FontSize = 10, ;
		Column2.Alignment = 0, ;
		Column2.ControlSource = "showdata.cname", ;
		Column2.Width = 182, ;
		Column2.ReadOnly = .T., ;
		Column2.Visible = .T., ;
		Column2.BackColor = RGB(196,221,255), ;
		Column2.Name = "colname", ;
		Column3.FontBold = .F., ;
		Column3.FontSize = 10, ;
		Column3.Alignment = 0, ;
		Column3.ControlSource = "showdata.clocation", ;
		Column3.Width = 338, ;
		Column3.ReadOnly = .T., ;
		Column3.Visible = .T., ;
		Column3.BackColor = RGB(196,221,255), ;
		Column3.Name = "collocation"


	ADD OBJECT frmwbrow.pgfbrowser.page1.grditems.coltype.hdrtype AS header WITH ;
		FontBold = .T., ;
		FontSize = 10, ;
		Alignment = 2, ;
		Caption = "Type", ;
		BackColor = RGB(226,195,193), ;
		Name = "hdrtype"


	ADD OBJECT frmwbrow.pgfbrowser.page1.grditems.coltype.txttype AS xtxtbasegrid WITH ;
		FontBold = .F., ;
		FontSize = 10, ;
		Alignment = 0, ;
		ReadOnly = .T., ;
		BackColor = RGB(196,221,255), ;
		Name = "txttype"


	ADD OBJECT frmwbrow.pgfbrowser.page1.grditems.colname.hdrname AS header WITH ;
		FontBold = .T., ;
		FontSize = 10, ;
		Alignment = 2, ;
		Caption = "Item Name", ;
		BackColor = RGB(226,195,193), ;
		Name = "hdrname"


	ADD OBJECT frmwbrow.pgfbrowser.page1.grditems.colname.txtname AS xtxtbasegrid WITH ;
		FontBold = .F., ;
		FontSize = 10, ;
		Alignment = 0, ;
		ReadOnly = .T., ;
		BackColor = RGB(196,221,255), ;
		Name = "txtname"


	ADD OBJECT frmwbrow.pgfbrowser.page1.grditems.collocation.hdrlocation AS header WITH ;
		FontBold = .T., ;
		FontSize = 10, ;
		Alignment = 2, ;
		Caption = "Location", ;
		BackColor = RGB(226,195,193), ;
		Name = "hdrlocation"


	ADD OBJECT frmwbrow.pgfbrowser.page1.grditems.collocation.txtlocation AS xtxtbasegrid WITH ;
		FontBold = .F., ;
		FontSize = 10, ;
		Alignment = 0, ;
		ReadOnly = .T., ;
		BackColor = RGB(196,221,255), ;
		Name = "txtlocation"


	ADD OBJECT frmwbrow.pgfbrowser.page2.oexplorer AS xbrowser WITH ;
		Top = 5, ;
		Left = 5, ;
		Height = 270, ;
		Width = 639, ;
		Name = "oExplorer"


	ADD OBJECT xcmdbaseexit1 AS xcmdbaseexit WITH ;
		Top = 315, ;
		Left = 574, ;
		Name = "Xcmdbaseexit1"


	ADD OBJECT cmdprint AS xcmdbaseaction WITH ;
		Top = 315, ;
		Left = 486, ;
		Caption = "Print", ;
		cmodeexpr = "IIF( ThisForm.pgfbrowser.ActivePage = 1, 'D', 'E' )", ;
		caction = "DoPrint", ;
		Name = "cmdPrint"


	ADD OBJECT cmdrefresh AS xcmdbaseaction WITH ;
		Top = 315, ;
		Left = 398, ;
		Caption = "Refresh", ;
		cmodeexpr = "IIF( ThisForm.pgfbrowser.ActivePage = 1, 'D', 'E' )", ;
		caction = "DoRefresh", ;
		Name = "cmdRefresh"


	ADD OBJECT cmdselall AS xcmdbaseaction WITH ;
		Top = 315, ;
		Left = 310, ;
		Caption = "Copy to Clip", ;
		cmodeexpr = "IIF( ThisForm.pgfbrowser.ActivePage = 1, 'D', 'E' )", ;
		caction = "DoCopy", ;
		Name = "cmdSelAll"


	*-- Sends content of the currently displayed document to printer. Prompts for user intervention.
	PROCEDURE doprint
		*** Call the Browser Control's Print method, prompt for printer
		WITH ThisForm.pgfbrowser.Page2.oExplorer
		  .execWB( OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER )
		ENDWITH
	ENDPROC


	*-- Refresh the currently displayed document
	PROCEDURE dorefresh
		*** Refresh the current page
		WITH ThisForm.pgfbrowser.Page2.oExplorer
		  .execWB( OLECMDID_REFRESH, OLECMDEXECOPT_DODEFAULT )
		ENDWITH
	ENDPROC


	*-- Select all in the current document, and copy to clipboard
	PROCEDURE docopy
		*** Select all and copy to clipboard
		*** Method [1] Using the ExecWB() method of the browser
		WITH ThisForm.pgfbrowser.Page2.oExplorer
		  .execWB( OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT )
		  .execWB( OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT )
		  .execWB( OLECMDID_CLEARSELECTION, OLECMDEXECOPT_DODEFAULT )
		ENDWITH

		*!*  *** Method [2] Using the Document Object
		*!*  WITH ThisForm.pgfbrowser.Page2.oExplorer
		*!*    .Document.ExecCommand( 'SelectAll', .F. )
		*!*    .Document.ExecCommand( 'Copy', .F. )
		*!*    .Document.ExecCommand( 'UnSelect', .F. )
		*!*  ENDWITH
	ENDPROC


	PROCEDURE pgfbrowser.Page1.Activate
		*** Update Controls
		ThisForm.RefreshForm( .T. )
	ENDPROC


	PROCEDURE pgfbrowser.Page2.Activate
		LOCAL lcTarget
		WITH This
		  lcTarget = (ALLTRIM( showdata.clocation ))
		  IF showdata.cType = "FILE"
		     *** Check that the file existS
		      IF FILE( ALLTRIM( lcTarget ) )
		        .oExplorer.Navigate( lcTarget )
		      ELSE
		        NODEFAULT
		        This.Parent.ActivePage = 1
		      ENDIF
		  ELSE
		    *** Just try and navigate to the specified location
		    .oExplorer.Navigate( lcTarget )
		  ENDIF
		  *** Update Controls
		  ThisForm.RefreshForm( .T. )  
		ENDWITH
	ENDPROC


	PROCEDURE hdrtype.Click
		WITH This.Parent
		    IF PEMSTATUS( .Parent, 'SetOrder', 5 )
		        IF .Parent.SetOrder( JUSTEXT( .ControlSource ) )
		            *** This column now has controlling index
		            FOR EACH loCol IN This.Parent.Parent.Columns
		                *** Clear the Header
		                IF loCol.Controls[1].Baseclass = 'Header'
		                    loCol.Controls[1].Caption = CHRTRAN( loCol.Controls[1].caption, ' §', '' )
		                ENDIF
		            NEXT
		            This.Caption = ALLTRIM( This.Caption ) + ' §'
		        ENDIF
		    ENDIF
		ENDWITH
	ENDPROC


	PROCEDURE hdrname.Click
		WITH This.Parent
		    IF PEMSTATUS( .Parent, 'SetOrder', 5 )
		        IF .Parent.SetOrder( JUSTEXT( .ControlSource ) )
		            *** This column now has controlling index
		            FOR EACH loCol IN This.Parent.Parent.Columns
		                *** Clear the Header
		                IF loCol.Controls[1].Baseclass = 'Header'
		                    loCol.Controls[1].Caption = CHRTRAN( loCol.Controls[1].caption, ' §', '' )
		                ENDIF
		            NEXT
		            This.Caption = ALLTRIM( This.Caption ) + ' §'
		        ENDIF
		    ENDIF
		ENDWITH
	ENDPROC


	PROCEDURE hdrlocation.Click
		WITH This.Parent
		    IF PEMSTATUS( .Parent, 'SetOrder', 5 )
		        IF .Parent.SetOrder( JUSTEXT( .ControlSource ) )
		            *** This column now has controlling index
		            FOR EACH loCol IN This.Parent.Parent.Columns
		                *** Clear the Header
		                IF loCol.Controls[1].Baseclass = 'Header'
		                    loCol.Controls[1].Caption = CHRTRAN( loCol.Controls[1].caption, ' §', '' )
		                ENDIF
		            NEXT
		            This.Caption = ALLTRIM( This.Caption ) + ' §'
		        ENDIF
		    ENDIF
		ENDWITH
	ENDPROC


ENDDEFINE
*
*-- EndDefine: frmwbrow
**************************************************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform