PureBasic Forum
http://forums.purebasic.com/english/

(Solved)how to open url webpage by clicking an image??
http://forums.purebasic.com/english/viewtopic.php?f=13&t=72957
Page 1 of 1

Author:  LESTROSO [ Tue Jun 04, 2019 6:35 pm ]
Post subject:  (Solved)how to open url webpage by clicking an image??

how to open url webpage by clicking an image?? i'm using macos x 10.13.6 and windows 10 ....

hi, i'm trying to launch a web page clicking on a credit image from my purebasic program...but without success ...can you help me please??

Best regards,Lestroso :oops:

Author:  RSBasic [ Tue Jun 04, 2019 6:43 pm ]
Post subject:  Re: how to open url webpage by clicking an image??

Code:
EnableExplicit

CreateImage(1, 100, 100, 24, RGB(255, 0, 0))

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ImageGadget(1, 10, 10, 100, 100, ImageID(1), 0)
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            RunProgram("https://www.google.de")
        EndSelect
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf


Or:
Code:
EnableExplicit

CreateImage(1, 100, 100, 24, RGB(255, 0, 0))

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(1, 10, 10, 100, 100, 0)
  If StartDrawing(CanvasOutput(1))
    DrawImage(ImageID(1), 0, 0)
    StopDrawing()
  EndIf
 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            Select EventType()
              Case #PB_EventType_LeftClick
                RunProgram("https://www.google.de")
            EndSelect
        EndSelect
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf

Author:  Shardik [ Tue Jun 04, 2019 8:04 pm ]
Post subject:  Re: how to open url webpage by clicking an image??

LESTROSO wrote:
i'm using macos x 10.13.6 and windows 10 ....

RSBasic's examples only work on Windows. On MacOS you have to use
Code:
RunProgram("Open", "https://www.google.de", "")

In this example in the German forum I demonstrated how to display a website in the default browser on Linux, MacOS and Windows.

Author:  LESTROSO [ Wed Jun 05, 2019 3:18 pm ]
Post subject:  Re: how to open url webpage by clicking an image??

I thank you very much!! it's all ok!! you have solved my problem....Best Regards, Lestroso :) :) :)

Author:  LESTROSO [ Thu Jun 06, 2019 9:44 pm ]
Post subject:  Re: how to open url webpage by clicking an image??

Dear friends...... i try to code this problem but i cant have success with it....My Simple problem is to click an image jpg and open the browser to google... i try this software..can you help me??? please ??? Lestroso :oops: :oops:


Code:
Global FasaImage
Procedure testaimmagini()
 
  Select EventGadget()
         
       Case #Fasaimage
                If EventType() = #PB_EventType_Change
                  Select GetGadgetState(#Fasaimage)
                                             
                    Case 1
                      Debug #fasaimage
            RunProgram("Open", "https://www.google.com", "") ; this for macintosh
            ;version windows RunProgram("https://www.google.de", "")

                 EndSelect

               EndIf
           EndSelect
           
EndProcedure


Author:  wombats [ Thu Jun 06, 2019 9:56 pm ]
Post subject:  Re: how to open url webpage by clicking an image??

It is best if you post a runnable program so that we can better see what you are trying to do. It's not clear what you're trying to do there - what type of gadget is #Fasaimage? Why do you check the EventGadget() in a procedure - is it bound to a gadget's event?

Author:  TI-994A [ Fri Jun 07, 2019 2:56 am ]
Post subject:  Re: how to open url webpage by clicking an image??

LESTROSO wrote:
...to click an image jpg and open the browser to google...

This should do it:
Code:
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
If OpenWindow(0, 0, 0, 200, 200, "ImageGadget", wFlags)
  yourImage = CreateImage(#PB_Any, 180, 180, 32, #Red) 
  imageGadget = ImageGadget(#PB_Any,  10, 10, 10, 10, ImageID(yourImage))
  Repeat   
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        appQuit = 1 
      Case #PB_Event_Gadget
        Select EventGadget()
          Case imageGadget
            CompilerIf #PB_Compiler_OS = #PB_OS_MacOS             
              RunProgram("Open", "https://www.google.com", "")
            CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
              RunProgram("https://www.google.de")
            CompilerEndIf           
        EndSelect       
    EndSelect
  Until appQuit
EndIf

Author:  LESTROSO [ Fri Jun 07, 2019 6:36 pm ]
Post subject:  Re: how to open url webpage by clicking an image??

Dear TI-994A,...your software example...clear my problem...i tryed your software and it works fine! I thank you very much...best regards, Lestroso :D :D :D

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/