Amiguinhos,
Vejamos algumas formas de trabalho com os recursos do sistema operacional.
A primeira delas usa o motor do
Internet Explorer através do acesso ao
InternetExplorer.Application
Código: Selecionar todos
cEndereco := "http://www.google.com"
oIE:=TOleAuto():New( "InternetExplorer.Application" )
//
oIE:Visible := .T.
oIE:ToolBar := .F.
oIE:StatusBar := .F.
oIE:MenuBar := .F.
//
oIE:Top := 055
oIE:Left := 001
oIE:Height := 600
oIE:Width := 800
//
oIE:Navigate( cEndereco )
//
if lPrint
oIE:ExecWB(6,0,0,0) // Imprimir
endif
oIE:End()
No segundo exemplo o acesso é feito pelo motor html do
Windows Explorer através do acesso ao
Shell.Explorer.
Código: Selecionar todos
cEndereco := "http://www.google.com"
oIE:=TOleAuto():New( "Shell.Explorer" )
oIE:MenuBar := .F.
oIE:Top := 055
oIE:Left := 001
oIE:Height := 600
oIE:Width := 800
oIE:Navigate( cEndereco )
oIE:End()
Outro exemplo usa um comando conhecido dos xHarbour´s:
Código: Selecionar todos
cEndereco := "http://www.google.com"
hE := CreateOleObject( "InternetExplorer.Application" )
OLESetProperty( hE, "Visible" , .T. )
OLESetProperty( hE, "ToolBar" , .F. )
OLESetProperty( hE, "StatusBar", .T. )
OLESetProperty( hE, "MenuBar" , .T. )
OLEInvoke( hE, "Navigate", cEndereco )
Uma coisa que reparei em
InternetExplorer.Application e
Shell.Explorer, no lugar do método
Navigate() é possivel usar
Navigate2() só não sei a diferença.
Outro trecho demonstra outras funções:
Código: Selecionar todos
cEndereco := "http://www.google.com"
oExplorer := TOleAuto():New( "InternetExplorer.Application" )
oExplorer:Navigate2( cEndereco )
//
do while oExplorer:ReadyState <> 4
HB_IDLESLEEP( 1 )
enddo
//
cNRevisao := oExplorer:Document:Body:InnerText
//
oExplorer:Quit()
Neste trecho o evento
oExplorer:ReadyState é testado para verificar travamento/leitura do motor.
O
oExplorer:Document:Body:InnerText é usado para recuperar a parte textual de uma página recuperada.
O método
Quit() é usado aqui, mas se der erro troque por
End().
Reparando no método Print do HarbourBoleto(um codigo entigo) vi que tinha o seguinte trecho:
Código: Selecionar todos
IF Os_IsWinNT()
PrintHTML(::Destino + ::Nomehtm, cPrinter, lPreview, lPromptPrint, !lPreview )
ELSE
ShellExecute(::Nomehtm, "print", NIL, ::Destino, 1)
ENDIF
Então acho que ele deva ficar parecido com isto:
Código: Selecionar todos
METHOD Print( lPreview, lPromptPrint, cPrinter ) CLASS oBoleto
DEFAULT lPreview TO ::lPreview ,;
lPromptPrint TO .T.,;
cPrinter TO GetDefaultPrinter()
IF ::lBoleto .AND. ::nBoletos > 0
if lUsarMotorIE
LOCAL oIE := CREATEOBJECT( "InternetExplorer.Application" )
oIE:Visible := .T.
// ... mais configurações
oIE:Navigate( ::Destino+"\"+ ::Nomehtm + " ")
else
// PrintHTML nao funciona no Win98 :-(
IF Os_IsWinNT()
// Caso nao seja Win98 usa PrintHTML
PrintHTML(::Destino + ::Nomehtm, cPrinter, lPreview, lPromptPrint, !lPreview )
ELSE
if lPreview
ShellExecute( ::Nomehtm, "Open", NIL, ::Destino, 1 )
else
ShellExecute( ::Nomehtm, "print", NIL, ::Destino, 1 )
endif
ENDIF
endif
ENDIF
RETURN Self
Codifiquei o trecho acima no olhômetro, nem testei.
Vamos trabalhar?