FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Mostrar imagen desde web
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Mostrar imagen desde web
Posted: Thu Aug 11, 2016 01:54 PM

Hola todos!
La pregunta es la siguiente: puedo mostrar en un dialogo una imagen que está alojada en un sitio web, en lugar de en un archivo de mi computadora?
Gracias a todos de ante mano.

Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Mostrar imagen desde web
Posted: Thu Aug 11, 2016 09:38 PM
Viendo un poco otros temas parecidos, pude sacar esto, por si a alguien le interesa
Code (fw): Select all Collapse
#include "fivewin.ch"
#include "Image.ch"

function Main()
LOCAL    oDlg, oImage, oGet,  lSetAlpha := .t., cUrlImage := SPACE(200)
        
        
   DEFINE DIALOG oDlg FROM 0, 0 TO 24, 60 

   @ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg SCROLL // ADJUST

   oImage:Progress( .f. )

   @ 6, 28 BUTTON "Exit" SIZE 50, 10 OF oDlg ACTION oDlg:End()
   
   @ 10, 26 CHECKBOX oImage:lStretch PROMPT "Ajustar" SIZE 50, 10 OF oDlg ;
      ON CHANGE ( oImage:ScrollAdjust(), oImage:Refresh() )

   @ 12 ,00 GET oGet VAR cUrlImage PICTURE "@S50" VALID(CambiaImagen(cUrlImage, oImage))
   ACTIVATE DIALOG oDlg CENTER
RETURN NIL

STATIC function CambiaImagen(url,oIm)
LOCAL nRet
nRet := DOWNLOADFILE( url, "C:\prueba.jpg" )
IF nRet = 0
   oIm:LoadBmp("C:\prueba.jpg" )
ENDIF   
RETURN nRet = 0

#pragma BEGINDUMP

    #include <Windows.h>
    #include <hbapi.h>
    #include <urlmon.h>

    HB_FUNC( DOWNLOADFILE )

    {
            HRESULT hr;
           
            hr = URLDownloadToFile( NULL, hb_parc( 1 ), hb_parc( 2 ), 0, NULL ) ;
           
            hb_retnl( hr ) ;
    }

    #pragma ENDDUMP
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Mostrar imagen desde web
Posted: Thu Aug 11, 2016 09:47 PM
Desde la versión de Abril de 2016

Code (fw): Select all Collapse
Bitmaps directly from URLs. It is now possible to create bitmaps and
  buttons directly from images on the web.
  Example:
     DEFINE BUTTON OF oWnd:oBar PROMPT "Aries" ;
      FILE "http://weknowyourdreamz.com/images/zodiac-01-aries-ram-icon.png"


viewtopic.php?f=16&t=32427#p190444
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Mostrar imagen desde web
Posted: Thu Aug 11, 2016 09:52 PM

Gracias Cristobal, voy a tener que actualizarme la versión de Fivewin, la mia no lo soporta...

Continue the discussion