How to make an image hyperlinked?

Just starting out? Need help? Post your questions and find answers here.
AlanFoo
Enthusiast
Enthusiast
Posts: 172
Joined: Fri Jul 24, 2009 6:24 am
Location: Malaysia

How to make an image hyperlinked?

Post by AlanFoo »

Hi hope you can help.

I need to be able to click an hyperlinked image?

what is the code to make the imagegadget hyperlinked?

Thanks for your help.

REgards
Alan
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: How to make an image hyperlinked?

Post by TI-994A »

AlanFoo wrote:...what is the code to make the imagegadget hyperlinked?
Hi Alan. Perhaps something like this:

Code: Select all

UseJPEGImageDecoder()
InitNetwork()

Enumeration
  #MainWindow
  #WebWindow
  #HyperLink1
  #HyperLink2
  #HyperLink3
  #img1
  #img2
  #img3
EndEnumeration

ReceiveHTTPFile("https://www.dropbox.com/s/igu72odknllgcaf/purebasicLogo.jpg?dl=1", 
                GetTemporaryDirectory() + "purebasicLogo.jpg")
imageFile.s = GetTemporaryDirectory() + "purebasicLogo.jpg"
LoadImage(#img1, imageFile)

ReceiveHTTPFile("https://www.dropbox.com/s/ewrlaf3vlobb0k0/googleLogo.jpg?dl=1", 
                GetTemporaryDirectory() + "googleLogo.jpg")
imageFile.s = GetTemporaryDirectory() + "googleLogo.jpg"
LoadImage(#img2, imageFile)

ReceiveHTTPFile("https://www.dropbox.com/s/g0iite3ucfyy196/purebasicForum.jpg?dl=1", 
                GetTemporaryDirectory() + "purebasicForum.jpg")
imageFile.s = GetTemporaryDirectory() + "purebasicForum.jpg"
LoadImage(#img3, imageFile)

wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, #PB_Any, #PB_Any, 700, 500, "Hyperlinked Images", wFlags)
WebGadget(#WebWindow, 10, 120, 680, 360, "http://www.purebasic.com") 
ImageGadget(#HyperLink1, 10, 10, 200, 100, ImageID(#img1))
ImageGadget(#HyperLink2, 250, 10, 200, 100, ImageID(#img2))
ImageGadget(#HyperLink3, 490, 10, 200, 100, ImageID(#img3))

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      appQuit = 1
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #HyperLink1
          Select EventType()
            Case #PB_EventType_LeftClick
              SetGadgetText(#WebWindow, "http://www.purebasic.com")
          EndSelect
        Case #HyperLink2
          Select EventType()
            Case #PB_EventType_LeftClick
              SetGadgetText(#WebWindow, "http://www.google.com")
          EndSelect
        Case #HyperLink3
          Select EventType()
            Case #PB_EventType_LeftClick
              SetGadgetText(#WebWindow, "http://www.purebasic.fr/english/viewtopic.php?p=445070#p445070")
          EndSelect
      EndSelect
  EndSelect
Until appQuit = 1
Hope it's what you're looking for. :D
EDITS wrote:18th February 2019: updated download links
Last edited by TI-994A on Mon Feb 18, 2019 6:25 am, edited 1 time in total.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
AlanFoo
Enthusiast
Enthusiast
Posts: 172
Joined: Fri Jul 24, 2009 6:24 am
Location: Malaysia

Re: How to make an image hyperlinked?

Post by AlanFoo »

Hi Ti994A,

Thanks. That is what I am looking for.

regards
Alan
Post Reply