From Web to image control

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
quartz565
Posts: 465
Joined: Mon Oct 01, 2012 12:37 pm
Location: Thessaloniki, Greece
Has thanked: 111 times
Been thanked: 11 times
Contact:

From Web to image control

Post by quartz565 » Fri Oct 27, 2017 3:21 pm

Hello my friends !
How download a image from a website and put it automatically into a image control ?
The name of the image I find is what I need.

Niko
Best Regards,
Nikos.

os: Windows Server 2012 - 64
hw: HP Server E5606, 2.13GHz, 8.00 GB - Intel Xeon CPU

User avatar
serge_girard
Posts: 1862
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 292 times
Been thanked: 67 times
Contact:

Post by serge_girard » Fri Oct 27, 2017 6:49 pm

Niko, Can you please explain more details/example about what you want?

Serge

User avatar
gfilatov
Posts: 514
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 7 times
Been thanked: 57 times
Contact:

Post by gfilatov » Fri Oct 27, 2017 7:02 pm

quartz565 wrote:
Fri Oct 27, 2017 3:21 pm
Hello my friends !
How download a image from a website and put it automatically into a image control ?
The name of the image I find is what I need.
Hello Niko,

It is possible with HMG Extended in the following easy way
Win_1.Image_1.Picture := cUrl
Please take a look for a working sample below:

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 * (c) 2017 Grigory Filatov <gfilatov@inbox.ru>
*/

#include <hmg.ch>

FUNCTION Main
   local cURL1 := "https://upload.wikimedia.org/wikipedia/commons/c/c8/Taj_Mahal_in_March_2004.jpg"
   local cURL2 := "http://cdn.history.com/sites/2/2015/04/hith-eiffel-tower-iStock_000016468972Large.jpg"

   define window win_1 ;
      main ;
      clientarea 800, 633 ;
      title "JPEG Image From URL" ;
      backcolor { 204, 220, 240 } nosize

      on key escape action win_1.release()

      DEFINE TOOLBAR ToolBar_1 BUTTONSIZE 100,16 FLAT

	BUTTON Button_1 ;
		CAPTION 'EiffelTower' ;
		ACTION ( Win_1.Image_1.Picture := cUrl2 ) ;
		TOOLTIP 'Load Eiffel Tower background'

	BUTTON Button_2 ;
		CAPTION 'TajMahal' ;
		ACTION ( Win_1.Image_1.Picture := cUrl1 ) ;
		TOOLTIP 'Load Taj Mahal background'

      END TOOLBAR

      define image image_1
         row 33
         col 0
         width 800
         height 600
         picture cURL2
         stretch .T.
      end image

   end window

   win_1.minbutton := .F.
   win_1.maxbutton := .F.

   win_1.center
   win_1.activate

RETURN NIL
Hope that useful :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

User avatar
quartz565
Posts: 465
Joined: Mon Oct 01, 2012 12:37 pm
Location: Thessaloniki, Greece
Has thanked: 111 times
Been thanked: 11 times
Contact:

Post by quartz565 » Sat Oct 28, 2017 11:19 am

Thanks Serge, Grigory

My English is very poor... but I will try to explain better what I would like:

1. In my program I create a url where the image name is the variable part of this url.
2. Through hyperlink control I do search on the web
3. When I choose between the many images, that interest me and which I will
        appears in my image control (as Grigorys example (thank you !)).
4. I'm going through my program by tapping save image as: to save it
      in a folder on the disc with a new image name.

is this possible?

Niko
Best Regards,
Nikos.

os: Windows Server 2012 - 64
hw: HP Server E5606, 2.13GHz, 8.00 GB - Intel Xeon CPU

KDJ
Posts: 178
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 190 times

Post by KDJ » Sat Oct 28, 2017 12:54 pm

Niko

How to download a file, see here: http://www.hmgforum.com/viewtopic.php?t=5321

KDJ
Posts: 178
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 190 times

Post by KDJ » Sat Oct 28, 2017 8:50 pm

This is an example in HMG:

ImageFromWeb.png
ImageFromWeb.png (185.43 KiB) Viewed 434 times
ImageFromWeb.zip
(1.99 KiB) Downloaded 47 times

User avatar
serge_girard
Posts: 1862
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 292 times
Been thanked: 67 times
Contact:

Post by serge_girard » Sun Oct 29, 2017 7:36 am

Great ! Thanks a lot, it could be very usefull !

Serge

User avatar
quartz565
Posts: 465
Joined: Mon Oct 01, 2012 12:37 pm
Location: Thessaloniki, Greece
Has thanked: 111 times
Been thanked: 11 times
Contact:

Post by quartz565 » Sun Oct 29, 2017 11:38 am

KDJ wrote:
Sat Oct 28, 2017 8:50 pm
This is an example in HMG:


ImageFromWeb.png


ImageFromWeb.zip
Thanks a lot my friend! I'll try it right away!
Niko
Best Regards,
Nikos.

os: Windows Server 2012 - 64
hw: HP Server E5606, 2.13GHz, 8.00 GB - Intel Xeon CPU

User avatar
Rathinagiri
Posts: 5172
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 136 times
Been thanked: 131 times
Contact:

Post by Rathinagiri » Sun Oct 29, 2017 2:27 pm

Wonderful KDJ!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
quartz565
Posts: 465
Joined: Mon Oct 01, 2012 12:37 pm
Location: Thessaloniki, Greece
Has thanked: 111 times
Been thanked: 11 times
Contact:

Post by quartz565 » Sun Oct 29, 2017 7:44 pm

Wonderful !!!
Thanks Krzysztof!
Best Regards,
Nikos.

os: Windows Server 2012 - 64
hw: HP Server E5606, 2.13GHz, 8.00 GB - Intel Xeon CPU

Post Reply