FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Imaqen desde Url solucionado ...
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Imaqen desde Url solucionado ...
Posted: Thu Dec 04, 2014 05:56 PM
Pues con este nuevo metodo para Timage ...
Falta que controle los posibles fallos si no existe la imagen en la url o asi, pero en principio funciona.Lo he probado con una imagen gif, jpg y png .
Tiene un problema y es que si llamamos a mas de una imagen , no llega a terminarse la carga de la imagen antes de que termine de la carga de la ventana .
Esto tendr铆a que controlarse con el evento OnResponseFinished pero no se como hacerlo as铆 que os lo dejo a vosotros.

Code (fw): Select all Collapse
METHOD LoadFromURL(cUrl ) CLASS TImage
local oHttp
local cResp 
聽 Try
聽 聽 聽 oHttp := CreateObject( "winhttp.winhttprequest.5.1" )
聽 聽 聽 oHttp:Open("GET", cUrl, .f. )
聽 聽 聽 oHttp:Send()
聽 聽 聽 cResp := oHttp:ResponseBody()
聽 Catch
聽 聽 聽 MsgStop( "Error" )
聽 聽 聽 Return .f.
聽 End Try
聽 
聽 聽::LoadFromMemory( cResp )
聽 聽::Refresh()
Return .t.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Imaqen desde Url solucionado ...
Posted: Fri Dec 05, 2014 07:11 AM

Manuel,

Sencillamente genial :-)

A帽adido ya para la pr贸xima versi贸n de FWH :-)

Muchas gracias!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 728
Joined: Fri Oct 07, 2005 07:38 AM
Re: Imaqen desde Url solucionado ...
Posted: Mon Dec 22, 2014 03:14 PM
Buenas, amigos. No consigo hacer funcionar este nuevo m茅todo. Lo he pasado a funci贸n para no modificar (de momento) la clase, pero no me carga ninguna imagen. He probado a grabarla por si era un tema de refresco o similar pero entonces "petarda" el ejemplo.

Aqu铆 dejo el c贸digo a ver si encontr谩is alg煤n fallo. Gracias.

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "Image.ch"

//----------------------------------------------------------------------------//

function Main()

聽 聽Local oDlg, oImage

聽 聽DEFINE DIALOG oDlg FROM 0, 0 TO 25, 60
聽 聽@ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg SCROLL // ADJUST

聽 聽@ 1, 28 BUTTON "URL" 聽 SIZE 50, 10 OF oDlg ACTION CargaImagenDesdeUrl (oImage,"http://forums.fivetechsupport.com/styles/prosilver/imageset/site_logo.gif")
聽 聽@ 2, 28 BUTTON "Salir" SIZE 50, 10 OF oDlg ACTION oDlg:End()
聽 聽
聽 聽ACTIVATE DIALOG oDlg CENTER

Return ( nil)

Function CargaImagenDesdeUrl (oImage,cUrl)
local oHttp
local cResp
聽 Try
聽 聽 聽 oHttp := CreateObject( "winhttp.winhttprequest.5.1" )
聽 聽 聽 oHttp:Open("GET", cUrl, .f. )
聽 聽 聽 oHttp:Send()
聽 聽 聽 cResp := oHttp:ResponseBody()
聽 Catch
聽 聽 聽 MsgStop( "Error cargando imagen" )
聽 聽 聽 Return .f.
聽 End Try

聽 聽oImage:LoadFromMemory( cResp )
聽 聽oImage:Refresh()
聽 聽msginfo (cUrl,"Imagen cargada")
Return (.t.)
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Imaqen desde Url solucionado ...
Posted: Mon Dec 22, 2014 04:02 PM

驴 usas un proxi ?

Posts: 728
Joined: Fri Oct 07, 2005 07:38 AM
Re: Imaqen desde Url solucionado ...
Posted: Mon Dec 22, 2014 04:16 PM

No, lo he probado en el trabajo y en casa con el mismo resultado.

Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
Posts: 1710
Joined: Tue Oct 28, 2008 06:26 PM
Re: Imaqen desde Url solucionado ...
Posted: Mon Dec 22, 2014 04:46 PM

Angel

Prob茅 tu ejemplo y funciona.

Antonio / Manuel

C贸mo se puede evitar la librer铆a freeimage.dll con FWH1412

Saludos,

Adhemar

Saludos,



Adhemar C.
Posts: 728
Joined: Fri Oct 07, 2005 07:38 AM
Re: Imaqen desde Url solucionado ...
Posted: Mon Dec 22, 2014 05:00 PM

Vaya, pues no s茅 a que pude ser debido ... :shock: :shock:

Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Imaqen desde Url solucionado ...
Posted: Mon Dec 22, 2014 05:52 PM

Adhemar,

Estamos en ello, a ver si finalmente podemos eliminarla.

De momento hay que seguir us谩ndola

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1710
Joined: Tue Oct 28, 2008 06:26 PM
Re: Imaqen desde Url solucionado ...
Posted: Mon Dec 22, 2014 06:37 PM

Perfecto.

Gracias.

Saludos,

Adhemar

Saludos,



Adhemar C.
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Imaqen desde Url solucionado ...
Posted: Tue Dec 23, 2014 10:25 AM
Antonio Linares wrote:Manuel,

Sencillamente genial :-)

A帽adido ya para la pr贸xima versi贸n de FWH :-)

Muchas gracias!



Antonio,
I think the mastintin method need a modify :

If the user Have a Proxy the method LoadFromURL(cUrl ) not run ok




to add proxy it can be

Code (fw): Select all Collapse
#define HTTPREQUEST_PROXYSETTING_DEFAULT 聽 0
#define HTTPREQUEST_PROXYSETTING_PRECONFIG 0
#define HTTPREQUEST_PROXYSETTING_DIRECT 聽 聽1
#define HTTPREQUEST_PROXYSETTING_PROXY 聽 聽 2


#define HTTPREQUEST_SETCREDENTIALS_FOR_SERVER 聽0
#define HTTPREQUEST_SETCREDENTIALS_FOR_PROXY 聽 1

METHOD LoadFromURL(cUrl ,lProxy, cUserName, cPassword,nPort,cProxy) CLASS TImage
local oHttp
local cResp 
聽 Try
聽 聽 聽oHttp := CreateObject( "winhttp.winhttprequest.5.1" )

聽 聽 聽 if lProxy
聽 聽 聽 聽 聽oHttp:SetProxy( HTTPREQUEST_PROXYSETTING_PROXY, cProxy+":"+alltrim(str(nPort)))
聽 聽 聽 endif


聽 聽 聽 oHttp:Open("GET", cUrl, .f. )

聽 聽 聽 聽 if lProxy
聽 聽 聽 聽 聽oHttp:SetCredentials(cUserName,cPassword,HTTPREQUEST_SETCREDENTIALS_FOR_PROXY)
聽 聽 聽 endif


聽 聽 聽 oHttp:Send()
聽 聽 聽 cResp := oHttp:ResponseBody()
聽 Catch
聽 聽 聽 MsgStop( "Error" )
聽 聽 聽 Return .f.
聽 End Try

聽 聽::LoadFromMemory( cResp )
聽 聽::Refresh()
Return .t.




I use it on Yahoo Meteo and Yahoo finance ( created by Mastintin)
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion