Advertising links
-
- Posts: 37
- Joined: Jan 26, 2017 7:54
Advertising links
Seems to me I read somewhere freebasic can open external web links. If so how can I do this?
Re: Advertising links
You could open a web address in the default browser through the shell.
Windows
This works in Ubuntu Linux
Example website button code:
Windows
Code: Select all
Shell "start http://www.freebasic.net/forum"
Code: Select all
Shell "xdg-open http://www.freebasic.net/forum"
Code: Select all
Screenres 640,480,32'Initiate screen
Dim as integer mx,my,click,lclick'mouse x and y,click and last click
do
screenlock
cls
'write the name of the link
Draw String (20,20),"FreeBASIC",rgb(255,255,255)
'make dashed border around the link
line (18,18)-(91,29),rgb(255,255,255),b,&b1001001001001001
'render underline if the mouse is hovering our link
if mx>=18 and mx<=91 and my>=18 and my<=29 then line (18,29)-(91,29),rgb(255,255,255)
screenunlock
getmouse mx,my,,click'get the mouse co-ords and button state
'If the mouse is hovering the button and the user has finished clicking then open the link in the default browser
#IFDEF __FB_LINUX__'Linux method
if mx>=18 and mx<=91 and my>=18 and my<=29 and click=0 and lclick=1 then Shell "xdg-open http://freebasic.net"
#ELSE 'Windows method
if mx>=18 and mx<=91 and my>=18 and my<=29 and click=0 and lclick=1 then Shell "start http://freebasic.net"
#ENDIF
'store this loop iteration's click value for the next iteration
lclick=click
'sleep to avoid cpu hogging
sleep 1
loop until multikey(1)