************************************************** *-- 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 **************************************************