[bb] Hyperlink label by Blaine [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:40

Previous topic - Next topic

BlitzBot

Title : Hyperlink label
Author : Blaine
Posted : 1+ years ago

Description : Adds blue hyperlink labels to your BlitzPlus programs, which, when clicked, will execute the file specified.

Note: Requires "GetSystemColor()"'s functions and userlib addons, and "Change Cursor Icon"'s userlib addons.

Here's how you'll use the functions:
"CreateHyperlink( label$ , x , y , width , height , link$ , parent [, style] )

label$ - text to be displayed
x,y,width,height - position and size of hyperlink
link$ - file to execute when clicking.  Can be a file, folder, or internet adress.
parent - parent gadget
style - this optional flag doesn't do anything.

Function will create a hyperlink label and return it's handle.  The hyperlinks will black out when they get moved, but they should come back up right after.  Also, they can have up to two lines of text (only happens if text is longer than size)."

"UpdateHyperlinks( )

Updates all hyperlink texts by keeping them displayed correctly, changing the mouse cursor, and executing the link.  Needs to go in your main program loop, just before a WaitEvent() command."


Code :
Code (blitzbasic) Select
Type hyperlink
Field canvas
Field href$
End Type


Function CreateHyperlink(txt$,x,y,w,h,link$,parent,style=0)
canvas=CreateCanvas(x,y,w,h,parent)
SetBuffer CanvasBuffer(canvas)
font=LoadFont("tahoma",13,0,0,1)
ClsColor getsyscolorr(15),getsyscolorg(15),getsyscolorb(15)
Cls
Color 0,0,255
SetFont font
If StringWidth(txt)>w
txt2$=txt
Repeat
txt2=Left(txt2,Len(txt2)-1)
Until StringWidth(txt2)<w
Text 0,0,txt2
Text 0,13,Right$(txt,Len(txt2)-3)
Else
Text 0,0,txt
EndIf
FlipCanvas canvas
l.hyperlink=New hyperlink
lcanvas=canvas
lhref=link
Return lcanvas
End Function


Function UpdateHyperlinks()
For l.hyperlink=Each hyperlink
If EventSource()=lcanvas
If EventID()=$203
SetCursor helpcursor
Else If EventID()=$201
ExecFile(lhref)
EndIf
EndIf
FlipCanvas lcanvas
Next
End Function


Comments :


Artemis(Posted 1+ years ago)

 where do i find the getsyscolor and change cursor iconuserlibsor in which dll are the in??


Blaine(Posted 1+ years ago)

 Alright, I'll just give them to you here:Userlib additions:
.lib "user32.dll"
GetSysColor%(Color%):"GetSysColor"
LoadCursor%( ID, Cursor ):"LoadCursorA"
SetCursor%( ID ):"SetCursor"
Added functions:Function GetSysColorR(SystemColor)
        Return (GetSysColor(SystemColor) And $000000FF)
End Function

Function GetSysColorG(SystemColor)
Return (GetSysColor(SystemColor) And $0000FF00) Shr 8
End Function

Function GetSysColorB(SystemColor)
Return (GetSysColor(SystemColor) And $00FF0000) Shr 16
End Function
Add those in and it should work. [/i]