Hyperlink into a button

Just starting out? Need help? Post your questions and find answers here.
ekix
User
User
Posts: 34
Joined: Thu Apr 21, 2005 7:43 pm
Location: Finland
Contact:

Hyperlink into a button

Post by ekix »

Hello guys

I'd like to add a button like "Visit my homepage" into a PB application and when someone clicks this button, it should open the default browser, and go to my web page.

I did not find this kind of example here, neither in the PB help

Could someone help me a bit.

Thanks/
Ekix
User avatar
chi
Addict
Addict
Posts: 1087
Joined: Sat May 05, 2007 5:31 pm
Location: Austria

Post by chi »

like this?

Code: Select all

Global Window_0, Button_0

Procedure Open_Window_0()
  
  Window_0 = OpenWindow(#PB_Any, 0, 0, 200, 70, "ButtonUrl Demo", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
  If Window_0
    If CreateGadgetList(WindowID(Window_0))
      Button_0 = ButtonGadget(#PB_Any, 10, 10, 180, 50, "visit my homepage")
    EndIf
  EndIf
EndProcedure

Open_Window_0()

Repeat
  Event = WaitWindowEvent()
  If Event = #PB_Event_Gadget
    Select EventGadget()
      Case Button_0
        RunProgram("http://www.google.com")
    EndSelect
  EndIf
Until Event = #PB_Event_CloseWindow
End
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Hyperlink into a button

Post by PB »

Why is your sig promoting the sale of cannabis?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
ekix
User
User
Posts: 34
Joined: Thu Apr 21, 2005 7:43 pm
Location: Finland
Contact:

Thanks

Post by ekix »

It works now as below

Code: Select all

 
If GadgetID = #Button_Home
     RunProgram("http://www.ekisoft.com")
EndIf
Ps. I did change my signature, look's like it's not popular here :=)
Post Reply